PDA

View Full Version : [CLOSED][3.0.0] ArrayStore problem



mschwartz
16 Jul 2009, 6:24 AM
I must be missing something about ArrayStore/ArrayReader.



new Ext.data.ArrayStore({
autoDestroy: true,
id: 'myid',
fields: [ { name: 'myid', type: 'int' }, { name: 'mytext' }],
data: [ { myId:"1", mytext:"value1"}, {myId:"2",mytext:"value2"}]
});
I step into ArrayReader.readRecords() and see a couple of things.

First:
line 33544 (ext-all-debug.js) for(var i = 0; i < root.length; i++) {
should be written:
for (var i=0,len=root.length; i<len; i++) {

Second:
33550 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
Is setting k to 0

So why isn't f.mapping getting set? Or maybe there's a bug in line 33550. maybe it should read like:
var k = (f.mapping !== undefined && f.mapping !==null) ? f.mapping : (f.name && f.name.length) ? f.name : j;

evant
16 Jul 2009, 6:26 AM
??

ArrayStore takes in an array of arrays:



new Ext.data.ArrayStore({
autoDestroy: true,
id: 'myid',
fields: [ { name: 'myid', type: 'int' }, { name: 'mytext' }],
data: [[1, "foo"], [2, "Bar"]]
});

mschwartz
16 Jul 2009, 6:28 AM
My bad, should be using jsonstore, but the for loop should be fixed :)

Condor
16 Jul 2009, 6:31 AM
My bad, should be using jsonstore, but the for loop should be fixed :)

Why? It isn't broken, it's just not very fast (if it's not optimized by the browser).

mschwartz
16 Jul 2009, 7:03 AM
Why? It isn't broken, it's just not very fast (if it's not optimized by the browser).

Seems like reading records into a store should be made as fast as possible, no?

Lukman
16 Jul 2009, 7:13 AM
I have the impression that array.length is just referring the 'length' member variable in the array object so it's not like it's iterating through all the array items to get the item count whenever you use array.length ... it's not like we are invoking a function call array.length(), is it?

evant
16 Jul 2009, 7:20 AM
Incredibly minor to the point of being negligible, changed in SVN anyhow.