[Mesa-dev] [PATCH] glsl: Pass ast_type_qualifier by const reference.

Iago Toral itoral at igalia.com
Tue Nov 24 02:34:13 PST 2015


On Mon, 2015-11-23 at 18:08 -0800, Matt Turner wrote:
> Coverity noticed that we were passing this by value, and it's 152 bytes.
> ---
>  src/glsl/ast.h                  | 10 +++++-----
>  src/glsl/ast_type.cpp           |  6 +++---
>  src/glsl/glsl_parser_extras.cpp |  2 +-
>  3 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/glsl/ast.h b/src/glsl/ast.h
> index 3bea63e..adfc793 100644
> --- a/src/glsl/ast.h
> +++ b/src/glsl/ast.h
> @@ -699,16 +699,16 @@ struct ast_type_qualifier {
>  
>     bool merge_qualifier(YYLTYPE *loc,
>  			_mesa_glsl_parse_state *state,
> -			ast_type_qualifier q);
> +			const ast_type_qualifier &q);
>  
>     bool merge_out_qualifier(YYLTYPE *loc,
>                             _mesa_glsl_parse_state *state,
> -                           ast_type_qualifier q,
> +                           const ast_type_qualifier &q,
>                             ast_node* &node);
>  
>     bool merge_in_qualifier(YYLTYPE *loc,
>                             _mesa_glsl_parse_state *state,
> -                           ast_type_qualifier q,
> +                           const ast_type_qualifier &q,
>                             ast_node* &node);
>  
>     ast_subroutine_list *subroutine_list;
> @@ -1152,7 +1152,7 @@ class ast_cs_input_layout : public ast_node
>  {
>  public:
>     ast_cs_input_layout(const struct YYLTYPE &locp,
> -                       ast_layout_expression **local_size)
> +                       ast_layout_expression *const *local_size)

I think this change does not belong in this patch. Otherwise:

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

>     {
>        for (int i = 0; i < 3; i++) {
>           this->local_size[i] = local_size[i];
> @@ -1197,6 +1197,6 @@ check_builtin_array_max_size(const char *name, unsigned size,
>  extern void _mesa_ast_process_interface_block(YYLTYPE *locp,
>                                                _mesa_glsl_parse_state *state,
>                                                ast_interface_block *const block,
> -                                              const struct ast_type_qualifier q);
> +                                              const struct ast_type_qualifier &q);
>  
>  #endif /* AST_H */
> diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
> index 03ed4dc..8643b7b 100644
> --- a/src/glsl/ast_type.cpp
> +++ b/src/glsl/ast_type.cpp
> @@ -116,7 +116,7 @@ ast_type_qualifier::interpolation_string() const
>  bool
>  ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
>  				    _mesa_glsl_parse_state *state,
> -				    ast_type_qualifier q)
> +				    const ast_type_qualifier &q)
>  {
>     ast_type_qualifier ubo_mat_mask;
>     ubo_mat_mask.flags.i = 0;
> @@ -293,7 +293,7 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
>  bool
>  ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
>                                          _mesa_glsl_parse_state *state,
> -                                        ast_type_qualifier q,
> +                                        const ast_type_qualifier &q,
>                                          ast_node* &node)
>  {
>     void *mem_ctx = state;
> @@ -309,7 +309,7 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
>  bool
>  ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
>                                         _mesa_glsl_parse_state *state,
> -                                       ast_type_qualifier q,
> +                                       const ast_type_qualifier &q,
>                                         ast_node* &node)
>  {
>     void *mem_ctx = state;
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index 84b3aca..7da4aba 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -874,7 +874,7 @@ void
>  _mesa_ast_process_interface_block(YYLTYPE *locp,
>                                    _mesa_glsl_parse_state *state,
>                                    ast_interface_block *const block,
> -                                  const struct ast_type_qualifier q)
> +                                  const struct ast_type_qualifier &q)
>  {
>     if (q.flags.q.buffer) {
>        if (!state->has_shader_storage_buffer_objects()) {




More information about the mesa-dev mailing list