소스 검색

update populate at formatResults to use bulk append of nodes

this will make a small (25%) improvement on speed.
ycdtosa 11 년 전
부모
커밋
0f8a85b994
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      select2.js

+ 5 - 1
select2.js

@@ -923,6 +923,8 @@ the specific language governing permissions and limitations under the Apache Lic
 
                         results = opts.sortResults(results, container, query);
 
+                        // collect the created nodes for bulk append
+                        var nodes = [];
                         for (i = 0, l = results.length; i < l; i = i + 1) {
 
                             result=results[i];
@@ -962,9 +964,11 @@ the specific language governing permissions and limitations under the Apache Lic
                             }
 
                             node.data("select2-data", result);
-                            container.append(node);
+                            nodes.push(node[0]);
                         }
 
+                        // bulk append the created nodes
+                        container.append(nodes);
                         liveRegion.text(opts.formatMatches(results.length));
                     };