Opened 10 years ago
Closed 10 years ago
#13989 closed defect (fixed)
dojo.store.Memory 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: |
Description
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 dojo.store.Memory({}); store.setData([{id: "X"}]); console.assert(store.get("X")); store.setData([{id: "Y"}]); console.assert(store.get("Y")); console.assert(store.get("X"));
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
comment:2 Changed 10 years ago by
Milestone: | tbd → 1.7 |
---|
this looks like a dup of #13727. just leaving it open for the sake of the optimization comment