The following javascript causes IE to think the script is unresponsive when there is a large dataset - can anyone help in making this more efficientas a side note chrome and firefox handle it just fine (at least with the datasets i've tried)
var count = 0; for (var i in control.nodeMap) count++; if (count == 0) { for (i = 0; i < locationGroupTreeView.Data.length; i++) { var node = locationGroupTreeView.Data[i]; control.nodeMap[node[3][0][1]] = locationGroupTreeView.findNodeById(node[3][0][1]); var characters = node[3][1][1].split(''); for (j = 0; j < characters.length; j++) { var character = characters[j].toLowerCase(); if (this.characterMap[character] == null) { this.characterMap[character] = new Object(); this.characterMap[character][node[3][0][1]] = true; } else { var index = this.linearSearch(node[3][0][1], this.characterMap[character]); if (index == -1) this.characterMap[character][node[3][0][1]] = true; } } } }
7/21/2010 10:52:36 AM
What are you trying to do?
7/21/2010 10:53:06 AM
it's a dropdown control that has a tree inside of it - this is enabling searching the tree - it loads each character into a hash mapthe problem occurs once there are a large number of nodes in the tree - IE throws an unresponsive warning after 5 million statements are executed (regardless of time) and this is the issue - it performs well but there are too many statements being executed for IE
7/21/2010 11:06:03 AM
How many items typically appear in your list? What is your expected maximum?
7/21/2010 11:09:07 AM
maybe im an idiot or something but idk how this would even work? you set count to 0, then the first thing you do in the top for loop is increment count. Then you check to see if count is 0 (which it wont ever be because you incremented it).[Edited on July 21, 2010 at 11:12 AM. Reason : k]
7/21/2010 11:12:13 AM
oh, hurrrrfaggot style braces. nevermind.
7/21/2010 11:12:44 AM
hahaha[Edited on July 21, 2010 at 11:13 AM. Reason : n/m]
7/21/2010 11:12:52 AM
allman style or get out
7/21/2010 11:15:04 AM
Also, is the options set static? If it is, why make the client build the hash every time the page is loaded? You could build the hash once and just pass 'em the object, ready to use.
7/21/2010 11:17:27 AM
i didn't write this - i'm just angry that it's shit i've already removed that ridiculous for loop at the beginning and just set count=1 as the last statement in the outside if statement - i'm not sure who thought that was acceptable^ great point - the data is not necessarily static but arguably it doesn't change "often" and when it did the hash map could be rebuilt then the issue is that i'd have to get another build of the entire project as opposed to updating this single javascript file that can be done "behind the scenes"]]
7/21/2010 11:17:51 AM
that nodemap[3][0][1] looks goofy as shit. idk wth it is or really anything about how people normally do javascript stuff, but i tell you waht i dont like it one bit. no sir
7/21/2010 11:20:24 AM
Without seeing some examples of this actually in use, I can say that you should probably do everything you can to minimize the size of the option list provided to the client. Maybe there's some way you could qualify what items are needed in the list based on other form inputs.I'm very much in favor of refining the process and interface first and the algorithm second. 'Cause really, hashing every character is only gonna give you an advantage in speed if the data set is HUGE, and if the data set for one measly list is that big, someone probably fucked up (or you'd be better off processing it server-side and passing the hash to the client when it's done [in which case you should probably just use an autocompleting text input field]).[Edited on July 21, 2010 at 11:23 AM. Reason : ...]
7/21/2010 11:20:49 AM
Can you post an example of what your data source looks like currently? I'm having trouble completely wrapping my head around what this is trying to do.
7/21/2010 11:42:48 AM