Skip to content

Commit ed8ff92

Browse files
authored
Always sort candidates (#10382)
* Always sort candidates * Sort candidates in Rust in Oxide engine Co-authored-by: Adam Wathan <[email protected]>
1 parent e17855b commit ed8ff92

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

oxide/crates/core/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn parse_all_blobs(blobs: Vec<Vec<u8>>) -> Vec<String> {
5454
let input: Vec<_> = blobs.iter().map(|blob| &blob[..]).collect();
5555
let input = &input[..];
5656

57-
input
57+
let mut result: Vec<String> = input
5858
.par_iter()
5959
.map(|input| Extractor::unique(input, Default::default()))
6060
.reduce(Default::default, |mut a, b| {
@@ -68,5 +68,7 @@ fn parse_all_blobs(blobs: Vec<Vec<u8>>) -> Vec<String> {
6868
// to a string.
6969
unsafe { String::from_utf8_unchecked(s.to_vec()) }
7070
})
71-
.collect()
71+
.collect();
72+
result.sort();
73+
result
7274
}

src/lib/expandTailwindAtRules.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,16 @@ export default function expandTailwindAtRules(context) {
163163
let classCacheCount = context.classCache.size
164164

165165
env.DEBUG && console.time('Generate rules')
166-
// TODO: Sorting is _probably_ slow, but right now it can guarantee the same order. Eventually
167-
// we will be able to get rid of this.
168166
env.DEBUG && console.time('Sorting candidates')
169-
let sortedCandidates =
170-
typeof process !== 'undefined' && process.env.JEST_WORKER_ID
171-
? new Set(
172-
[...candidates].sort((a, z) => {
173-
if (a === z) return 0
174-
if (a < z) return -1
175-
return 1
176-
})
177-
)
178-
: candidates
167+
let sortedCandidates = env.OXIDE
168+
? candidates
169+
: new Set(
170+
[...candidates].sort((a, z) => {
171+
if (a === z) return 0
172+
if (a < z) return -1
173+
return 1
174+
})
175+
)
179176
env.DEBUG && console.timeEnd('Sorting candidates')
180177
generateRules(sortedCandidates, context)
181178
env.DEBUG && console.timeEnd('Generate rules')

0 commit comments

Comments
 (0)