Opened 10 years ago

Closed 10 years ago

#13989 closed defect (fixed) optimization and question

Reported by: rmaccracken Owned by: Kris Zyp
Priority: high Milestone: 1.7
Component: Data Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:


First - an optimization. The "add" function first checks to see if the id is already in the store. If not, then it calls "put". But in "put" it iterates through the data array looking to replace the object at that id. In the case of "add" the entire for loop can be skipped.

"put" looks like it will handle both new and existing ids. In that case, you can just check if the id is in the index and decide whether the for loop is necessary.

Second - a question about "setData". The following code passes through with no assertions.

var store = new{});

store.setData([{id: "X"}]);

store.setData([{id: "Y"}]);

Is this intended? The index is not reset when "setData" is called the second time, so "get" will return a valid object for "X" even though it is no longer in the data array.

Change History (3)

comment:1 Changed 10 years ago by ben hockey

this looks like a dup of #13727. just leaving it open for the sake of the optimization comment

comment:2 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [26723]:

Optimize Memory store for better add()/put() performance, reset index on setData, fixes #13989, fixes #13727 !strict

comment:2 Changed 10 years ago by bill

Milestone: tbd1.7
Note: See TracTickets for help on using tickets.