ivaynberg/select2 — pull request #2111 by TrevorBurnham (2014-02-11 22:05:08+00:00)
Title: When adding n values to multi, avoiding looping over them n times

@ivaynberg Currently, every time you call `$input.select2('val', array)`, the `setVal()` function is called for every array entry, and `setVal()` loops over the entire array of values to ensure uniqueness. When the number of values being set is fairly large (on the order of hundreds), this has a dramatic impact on rendering performance.

This commit adds a new internal method, `setUniqueVal()`, to call when a value array is already known to be unique (as is the case when the call originates from `updateSelection`).