History

Update editEntitiesWithTag to use static lookup table

Ryan Huffman committed 10 years ago

Commit 02347471 parent 1f25ba81 file · +12 −6Browse files

Showing the changes to tutorial/tutorial.js (1 of 1 file). Show all

Unified · Split

tutorial/tutorial.js+12−6
@@ -201,12 +201,18 @@ function deleteEntitiesWithTag(tag) { · 200 unmodified lines
201201 }
202202 }
203203 function editEntitiesWithTag(tag, propertiesOrFn) {
204− var entityIDs = findEntitiesWithTag(tag);
205− for (var i = 0; i < entityIDs.length; ++i) {
206− if (isFunction(propertiesOrFn)) {
207− Entities.editEntity(entityIDs[i], propertiesOrFn(entityIDs[i]));
208− } else {
209− Entities.editEntity(entityIDs[i], propertiesOrFn);
204+ //var entityIDs = findEntitiesWithTag(tag);
205+ var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag];
206+
207+ debug("Editing tag: ", tag);
208+ if (entities) {
209+ for (entityID in entities) {
210+ debug("Editing: ", entityID, ", ", propertiesOrFn, ", Is in local tree: ", isEntityInLocalTree(entityID));
211+ if (isFunction(propertiesOrFn)) {
212+ Entities.editEntity(entityID, propertiesOrFn(entityIDs[i]));
213+ } else {
214+ Entities.editEntity(entityID, propertiesOrFn);
215+ }
210216 }
211217 }
212218 }