diff options
author | frosch <frosch@openttd.org> | 2018-03-11 13:17:44 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2018-03-11 13:17:44 +0000 |
commit | 4fc178aebd65bbdccead5122ae45e2bdcf752a4e (patch) | |
tree | 46279d06535470fed6e743223e1dd48ca78f5509 | |
parent | db54db00df7390443cdb35139a702af14cb79b90 (diff) | |
download | openttd-4fc178aebd65bbdccead5122ae45e2bdcf752a4e.tar.xz |
(svn r27982) -Codechange: Reduce invocations of GetGlobalVariable. Speedup sprite resolving by about 3 percent.
-rw-r--r-- | src/newgrf_spritegroup.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index a838a1388..96ebdf093 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -60,11 +60,7 @@ RandomizedSpriteGroup::~RandomizedSpriteGroup() static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available) { - /* First handle variables common with Action7/9/D */ uint32 value; - if (GetGlobalVariable(variable, &value, object.grffile)) return value; - - /* Non-common variable */ switch (variable) { case 0x0C: return object.callback; case 0x10: return object.callback_param1; @@ -79,8 +75,11 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc if (object.grffile == NULL) return 0; return object.grffile->GetParam(parameter); - /* Not a common variable, so evaluate the feature specific variables */ - default: return scope->GetVariable(variable, parameter, available); + default: + /* First handle variables common with Action7/9/D */ + if (variable < 0x40 && GetGlobalVariable(variable, &value, object.grffile)) return value; + /* Not a common variable, so evaluate the feature specific variables */ + return scope->GetVariable(variable, parameter, available); } } |