Skip to content

Commit 85cf8c3

Browse files
committed
Using key lookup instead of searching array when building option groups.
1 parent 84e5b15 commit 85cf8c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/jquery.multiselect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
var o = this.options;
133133
var menu = this.menu;
134134
var checkboxContainer = this.checkboxContainer;
135-
var optgroups = [];
135+
var optgroups = {};
136136
var html = "";
137137
var id = el.attr('id') || multiselectID++; // unique ID for the label & option tags
138138

@@ -164,15 +164,15 @@
164164
optLabel = parent.getAttribute('label');
165165

166166
// has this optgroup been added already?
167-
if($.inArray(optLabel, optgroups) === -1) {
167+
if(!optgroups[optLabel]) {
168168
var optLabelEscaped = optLabel.replace(/&/g, '&')
169169
.replace(/>/g, '>')
170170
.replace(/</g, '&lt;')
171171
.replace(/'/g, '&#39;')
172172
.replace(/\//g, '&#x2F;')
173173
.replace(/"/g, '&quot;');
174174
html += '<li class="ui-multiselect-optgroup-label ' + parent.className + '"><a href="#">' + optLabelEscaped + '</a></li>';
175-
optgroups.push(optLabel);
175+
optgroups[optLabel] = true;
176176
}
177177
}
178178

0 commit comments

Comments
 (0)