From 0f8a85b9945055b369d500a6eeb4757f8c5050ff Mon Sep 17 00:00:00 2001 From: ycdtosa Date: Tue, 13 May 2014 12:27:31 +0200 Subject: [PATCH] update populate at formatResults to use bulk append of nodes this will make a small (25%) improvement on speed. --- select2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 580d32ed..49abd8a1 100644 --- a/select2.js +++ b/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)); };