use parseCandidateStrings directly (#11332)

+ drop the `parseCandidateStringsFromFiles` since this can be
  implemented using `parseCandidateStrings` already.
This commit is contained in:
Robin Malfait 2023-06-01 13:24:53 +02:00 • committed by GitHub
parent 352c563d99
commit 5c7a8e98ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 19 deletions

View file

@ -24,5 +24,5 @@ name = "parse_candidates"
harness = false
[[bench]]
name = "parse_candidate_strings_from_files"
name = "parse_candidate_strings"
harness = false

View file

@ -1,6 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use std::path::PathBuf;
use tailwindcss_core::{parse_candidate_strings_from_files, ChangedContent};
use tailwindcss_core::{parse_candidate_strings, ChangedContent, Parsing, IO};
pub fn criterion_benchmark(c: &mut Criterion) {
// current_dir will be set to ./crates/core
@ -51,8 +51,13 @@ pub fn criterion_benchmark(c: &mut Criterion) {
})
.collect();
c.bench_function("parse_candidate_strings_from_files", |b| {
b.iter(|| parse_candidate_strings_from_files(changed_content.clone()))
c.bench_function("parse_candidate_strings", |b| {
b.iter(|| {
parse_candidate_strings(
changed_content.clone(),
Parsing::Parallel as u8 | IO::Parallel as u8,
)
})
});
}

View file

@ -335,11 +335,6 @@ impl From<u8> for Parsing {
}
}
pub fn parse_candidate_strings_from_files(changed_content: Vec<ChangedContent>) -> Vec<String> {
init_tracing();
parse_all_blobs(read_all_files(changed_content))
}
pub fn parse_candidate_strings(input: Vec<ChangedContent>, options: u8) -> Vec<String> {
init_tracing();

View file

@ -22,13 +22,6 @@ impl From<ChangedContent> for tailwindcss_core::ChangedContent {
}
}
#[napi]
pub fn parse_candidate_strings_from_files(changed_content: Vec<ChangedContent>) -> Vec<String> {
tailwindcss_core::parse_candidate_strings_from_files(
changed_content.into_iter().map(Into::into).collect(),
)
}
#[derive(Debug, Clone)]
#[napi(object)]
pub struct ContentPathInfo {

View file

@ -1,6 +1,6 @@
import fs from 'fs'
import LRU from '@alloc/quick-lru'
import { parseCandidateStringsFromFiles } from '@tailwindcss/oxide'
import { parseCandidateStrings, IO, Parsing } from '@tailwindcss/oxide'
import * as sharedState from './sharedState'
import { generateRules } from './generateRules'
import log from '../util/log'
@ -134,8 +134,9 @@ export default function expandTailwindAtRules(context) {
if (flagEnabled(context.tailwindConfig, 'oxideParser')) {
// TODO: Pass through or implement `extractor`
for (let candidate of parseCandidateStringsFromFiles(
context.changedContent
for (let candidate of parseCandidateStrings(
context.changedContent,
IO.Parallel | Parsing.Parallel
// Object.assign({}, builtInTransformers, context.tailwindConfig.content.transform)
)) {
candidates.add(candidate)