Skip to content

Commit 77a32df

Browse files
committed
Use Node.js sort instead of timsort
As it's faster: #328 (comment)
1 parent 6b9a44a commit 77a32df

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

lib/modules/sortAttributes.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { sort as timSort } from 'timsort';
2-
31
const validOptions = new Set(['frequency', 'alphabetical']);
42

53
const processModuleOptions = options => {
@@ -27,7 +25,7 @@ class AttributeTokenChain {
2725

2826
createSortOrder() {
2927
let _sortOrder = [...this.freqData.entries()];
30-
timSort(_sortOrder, (a, b) => b[1] - a[1]);
28+
_sortOrder.sort((a, b) => b[1] - a[1]);
3129

3230
this.sortOrder = _sortOrder.map(i => i[0]);
3331
}

lib/modules/sortAttributesWithLists.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// class, rel, ping
2-
import { sort as timSort } from 'timsort';
32
import { attributesWithLists } from './collapseAttributeWhitespace.mjs';
43

54
const validOptions = new Set(['frequency', 'alphabetical']);
@@ -26,7 +25,7 @@ class AttributeTokenChain {
2625

2726
createSortOrder() {
2827
let _sortOrder = [...this.freqData.entries()];
29-
timSort(_sortOrder, (a, b) => b[1] - a[1]);
28+
_sortOrder.sort((a, b) => b[1] - a[1]);
3029

3130
this.sortOrder = _sortOrder.map(i => i[0]);
3231
}

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
},
6464
"dependencies": {
6565
"cosmiconfig": "^9.0.0",
66-
"posthtml": "^0.16.5",
67-
"timsort": "^0.3.0"
66+
"posthtml": "^0.16.5"
6867
},
6968
"devDependencies": {
7069
"@aminya/babel-plugin-replace-import-extension": "1.2.0",

0 commit comments

Comments
 (0)