本文介绍了大数组迭代(200000) - 任何优化机会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好! 我的项目有以下界面:(截图效果最好) http://www.screencast.com/users/asch...9-4a7af883e3c9 设备组可以有1台设备或100,000台设备。 当您选择其他设备组时,我有异步操作 - 它将转到服务器,获取适用的设备 - 从列表中删除 当前设备,然后重新添加它拥有的所有设备 检索。 这需要很长时间,大约20,000个设备(20-30秒)。 这是我的代码: //结果是一个字符串数组 函数populateDeviceList(结果){ var listBox = $(''。DeviceList '')[0]; //清除列表 for(var i = listBox.options.length - 1; i > = 0; i--){ listBox.options [i] = null; } //重新填充结果 var deviceListFilterBox = $(''。DeviceListFilterBox'')[0] .value; var len = result.length; for(var i = 0; i< len; i ++){ var thisOne = result [i]; if(thisOne.startsWith(deviceListFilterBox)){ AddItem(listBox ,thisOne,thisOne); } } disableSelectedItems($(''body'')); } 函数AddItem(objListBox,strText,strId,added) { var newOption = new Option(strText) ,strId) objListBox.options.add(newOption); } 有什么建议吗? 提前致谢!Hello!My project has the following interface: (screenshot works the best) http://www.screencast.com/users/asch...9-4a7af883e3c9Device groups could have 1 device, or 100,000 devices.I have an asynchronous action when you select a different device group- it will go to the server, get the applicable devices - remove thecurrent devices from the list, then re-add all the devices it hasretrieved.This takes a long time with around 20,000 devices (20-30 seconds).Here''s my code://result is an array of stringsfunction populateDeviceList(result){var listBox = $(''.DeviceList'')[0];//Clear the listfor (var i = listBox.options.length - 1 ; i >= 0 ; i--) {listBox.options[i] = null;}//Repopulate with resultsvar deviceListFilterBox = $(''.DeviceListFilterBox'')[0].value;var len = result.length;for (var i = 0;i < len;i++){var thisOne = result[i];if (thisOne.startsWith(deviceListFilterBox)){AddItem(listBox, thisOne, thisOne);}}disableSelectedItems($(''body''));}function AddItem(objListBox, strText, strId, added){var newOption = new Option(strText, strId)objListBox.options.add(newOption);}Any suggestions?Thanks in advance!推荐答案 这篇关于大数组迭代(200000) - 任何优化机会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-16 01:21