File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -246,10 +246,7 @@ export default function (vm) {
246
246
lookupBlocks = vm . runtime . flyoutBlocks ;
247
247
}
248
248
const sort = function ( options ) {
249
- options . sort ( ( str1 , str2 ) => str1 . localeCompare ( str2 , [ ] , {
250
- sensitivity : 'base' ,
251
- numeric : true
252
- } ) ) ;
249
+ options . sort ( ScratchBlocks . scratchBlocksUtils . compareStrings ) ;
253
250
} ;
254
251
// Get all the stage variables (no lists) so we can add them to menu when the stage is selected.
255
252
const stageVariableOptions = vm . runtime . getTargetForStage ( ) . getAllVariableNamesInScopeByType ( '' ) ;
@@ -323,5 +320,16 @@ export default function (vm) {
323
320
vm . runtime . emit ( 'PLAY_NOTE' , noteNum , extensionId ) ;
324
321
} ;
325
322
323
+ // Use a collator's compare instead of localeCompare which internally
324
+ // creates a collator. Using this is a lot faster in browsers that create a
325
+ // collator for every localeCompare call.
326
+ const collator = new Intl . Collator ( [ ] , {
327
+ sensitivity : 'base' ,
328
+ numeric : true
329
+ } ) ;
330
+ ScratchBlocks . scratchBlocksUtils . compareStrings = function ( str1 , str2 ) {
331
+ return collator . compare ( str1 , str2 ) ;
332
+ } ;
333
+
326
334
return ScratchBlocks ;
327
335
}
You can’t perform that action at this time.
0 commit comments