Page MenuHomeWildfire Games

Delete copy-assignment GUIUtil GetSetting variant
ClosedPublic

Authored by elexis on Aug 23 2019, 5:57 AM.

Details

Summary

rP22693 introduced a non-copying GetSetting variant, since using GetSettingPointer is ugly and since GetSetting performs a copy when a reference is sufficient and more performant for non-primitives.

GetSetting returning a reference has the advantage that one can collapse a bunch of code, one can inline the function call.
So one doesnt have to declare a variable, assign the default value, then assign the setting value, and then use the setting value but can do it all in one step.

Another advantage of the new variant, as revealed by this patch, is that it shows some unused variables whereas before it didn't.
Since the new GetSetting can do everything the previous GetSetting can do but in better, this patch removes the old function variant.

Another advantage is that the variables can become constants.

This patch avoids many copies of CStr and CStrW, even for Draw calls.

(This GetSetting variant might have been a nicer fix than rP1518.)

Test Plan

Check that no code behavior change is introduced. Most importantly check that nothing uses a reference and changes the value later, unless that was already the case.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Aug 23 2019, 5:57 AM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/gui/GUIutil.h
|  35| template<typename·T>·class·GUI;
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'template<...' is invalid C code. Use --std or --language to configure the language.

source/gui/GUITooltip.cpp
|   1| /*·Copyright·(C)·2016·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2016"
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/460/display/redirect

elexis edited the summary of this revision. (Show Details)Aug 23 2019, 11:44 AM
This revision was not accepted when it landed; it landed in state Needs Review.Aug 23 2019, 4:43 PM
This revision was automatically updated to reflect the committed changes.
elexis updated the Trac tickets for this revision.Aug 29 2019, 11:21 AM