Always sort candidates (#10382)

* Always sort candidates

* Sort candidates in Rust in Oxide engine

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
This commit is contained in:
Adam Wathan 2023-01-21 10:52:02 -05:00 • committed by GitHub
parent e17855b4d4
commit ed8ff92b03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View file

@ -54,7 +54,7 @@ fn parse_all_blobs(blobs: Vec<Vec<u8>>) -> Vec<String> {
let input: Vec<_> = blobs.iter().map(|blob| &blob[..]).collect();
let input = &input[..];
input
let mut result: Vec<String> = input
.par_iter()
.map(|input| Extractor::unique(input, Default::default()))
.reduce(Default::default, |mut a, b| {
@ -68,5 +68,7 @@ fn parse_all_blobs(blobs: Vec<Vec<u8>>) -> Vec<String> {
// to a string.
unsafe { String::from_utf8_unchecked(s.to_vec()) }
})
.collect()
.collect();
result.sort();
result
}

View file

@ -163,19 +163,16 @@ export default function expandTailwindAtRules(context) {
let classCacheCount = context.classCache.size
env.DEBUG && console.time('Generate rules')
// TODO: Sorting is _probably_ slow, but right now it can guarantee the same order. Eventually
// we will be able to get rid of this.
env.DEBUG && console.time('Sorting candidates')
let sortedCandidates =
typeof process !== 'undefined' && process.env.JEST_WORKER_ID
? new Set(
[...candidates].sort((a, z) => {
if (a === z) return 0
if (a < z) return -1
return 1
})
)
: candidates
let sortedCandidates = env.OXIDE
? candidates
: new Set(
[...candidates].sort((a, z) => {
if (a === z) return 0
if (a < z) return -1
return 1
})
)
env.DEBUG && console.timeEnd('Sorting candidates')
generateRules(sortedCandidates, context)
env.DEBUG && console.timeEnd('Generate rules')