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

small refactoring in globals.cpp

<< < (4/7) > >>

frithjofh:
@obfuscated

the change to StartsWith() was merely visual. i tried both versions and the StartsWith() seemed to me to result in a cleaner image to the eye, making it easier and faster to grasp that there are three separate conditions...

as I said, only a personal impression... blame my eyesight ;)

frithjofh:
please revise and test attached corrected patch...

MortenMacFly:

--- Quote from: frithjofh on February 05, 2016, 12:51:20 pm ---please revise and test attached corrected patch...

--- End quote ---
Sorry, but for me, this patch does not apply on SVN head, unfortunately.

frithjofh:
i will correct it...

oBFusCATed:

--- Quote from: frithjofh on February 05, 2016, 11:41:39 am ---doing three separate iterations on the array results in the code running much faster due to more cache locality.

--- End quote ---
The code runs faster because you've removed the calls to wxString::Remove.
This call is removing characters from the beginning of the string and copying the rest of the string to the front.
So the improvement is not because of better cache locality, but because there is less copying.


--- Quote from: frithjofh on February 05, 2016, 11:41:39 am ---for instance, the original version repeated the test for the value of trimspaces in each iteration. now it is done only once.

--- End quote ---
Probably the compiler has re-written the loop and has extracted the test outside of it.
I'm sure that if you remove the check from the original version it won't change its performance!


--- Quote from: frithjofh on February 05, 2016, 11:41:39 am ---same for the third iteration of removing empty entries.

--- End quote ---
Why do you need to add elements and then remove them?


--- Quote from: frithjofh on February 05, 2016, 11:41:39 am ---the part of the extra whole copy I don't understand. do you mean in the return statement?

--- End quote ---
The return statement is doing a redundant copy.

p.p. this post is made before I've looked at the latest patch.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version