Hi! 

On 20 Apr 2017 06:10, "Alexander Barkov" <bar@mariadb.org> wrote:
Hello all,


Monty is now doing refactoring:

1. Replacing a lot of LEX_STRING to LEX_CSTRING.

2. Fixing functions and methods that have arguments of types:
a. pointer "const LEX_STRING *name" and
b. reference "const LEX_STRING &name".
to the same style. Monty chose passing by pointer (2a).


I think that:

- #1 is good.
- #2 is good, in the sense of changing to the same style.

But I think that the choice of "passing by pointer" in #2 is bad.
Passing by reference for LEX_STRING/LEX_CSTRING related things would be
better.


With the "passing by pointer" approach whenever one needs to pass
a LEX_STRING to a function accepting LEX_CSTRING, one will have to do:


void func1(const LEX_STRING *str)
{
  LEX_CSTRING tmp= {str->str, str->length};
  func2(&tmp);
}

The above is not a problem:

- We don't have less than 5 places in the code where LEX_STRING is changed to LEX_CSTRING. 
- In these places one can do this with a simple cast, nothing elaborated. 


I'd propose two things instead:

1. Add a class:

No reason to make a complex solution for a problem that doesn't exist. 


2. Instead of "const LEX_CSTRING *str"
we use "const Lex_cstring &str" all around C++ code.

No, no, no. 

I do not want to use & anywhere as arguments in the code. It hides things and lends people to do errors like we had before where they declared some functions to take full structure she references in other places, which creates a mess. 

Regards, 
Monty