Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

small refactoring in globals.cpp

(1/7) > >>

frithjofh:
hi everybody,

took a look into file globals.cpp and I prose some refactoring of three functions:

- general code clean up
- improved readability
- simplification of logic
- removed some duplication
- speed up measured to be about 14% due, I suppose, to more cache locality (all is relative: on my machine, with my test case,... )

regards

frithjof

oBFusCATed:
GetVectorFromString should not call wxArrayString, because there is an additional copy!

frithjofh:
because first I have a const wxArrayString and then return a std::vector ?

my thoughts were: in the original function I have two vector's, one for the values in the function and the other as a copy during the return.

Now I have one wxArrayString and because the function is so "short" the unnamed object which is returned gets the benefit of RVO. so there are at most the same number of containers, at best even one less. the original function cannot count on RVO imho.

but maybe I get something wrong here...

thx for he feedback

frithjofh:
nah... I think you are right... there is an extra copy of the array... damm

frithjofh:
so maybe make a template function out of it in order to not textually duplicate the code... what do you think?

never mind... i am too tired to think strait

Navigation

[0] Message Index

[#] Next page

Go to full version