Ticket #2475: map_replacement.diff

File map_replacement.diff, 2.5 KB (added by Yves, 10 years ago)

performance testpatch (can be committed if the decision is positive)

  • binaries/data/mods/public/simulation/ai/common-api/entity.js

     
    88    _init: function(template)
    99    {
    1010        this._template = template;
    11         this._tpCache = {};
     11        this._tpCache = new Map();
    1212    },
    1313   
    1414    // helper function to return a template value, optionally adjusting for tech.
     
    1818        var value = this._template;
    1919        if (this._auraTemplateModif && this._auraTemplateModif[string])     {
    2020            return this._auraTemplateModif[string];
    21         } else if (this._techModif && this._techModif[string]) {
    22             return this._techModif[string];
     21        } else if (this._techModif && this._techModif.has(string)) {
     22            return this._techModif.get(string);
    2323        } else {
    24             if (this._tpCache[string] == null)
     24            if (!this._tpCache.has(string))
    2525            {
    2626                var args = string.split("/");
    2727                for (var i = 0; i < args.length; ++i)
     
    3232                        value = undefined;
    3333                        break;
    3434                    }
    35                 this._tpCache[string] = value;
     35                this._tpCache.set(string, value);
    3636            }
    37             return this._tpCache[string];
    38         }
     37            return this._tpCache.get(string);
     38        }
     39 
    3940    },
    4041
    4142    genericName: function() {
     
    513514        this._auraTemplateModif = {};   // template modification from auras. this is only for this entity.
    514515        this._ai = sharedAI;
    515516        if (!sharedAI._techModifications[entity.owner][this._templateName])
    516             sharedAI._techModifications[entity.owner][this._templateName] = {};
     517            sharedAI._techModifications[entity.owner][this._templateName] = new Map();
    517518        this._techModif = sharedAI._techModifications[entity.owner][this._templateName]; // save a reference to the template tech modifications
    518519    },
    519520
  • binaries/data/mods/public/simulation/ai/common-api/shared.js

     
    340340        {
    341341            var changes = playerDiff[template];
    342342            if (!this._techModifications[player][template])
    343                 this._techModifications[player][template] = {};
     343                this._techModifications[player][template] = new Map();
    344344            for each (var change in changes)
    345                 this._techModifications[player][template][change.variable] = change.value;
     345                this._techModifications[player][template].set(change.variable, change.value);
    346346        }
    347347    }
    348348    Engine.ProfileStop();