use parseCandidateStrings directly (#11332)
+ drop the `parseCandidateStringsFromFiles` since this can be implemented using `parseCandidateStrings` already.
This commit is contained in:
parent
352c563d99
commit
5c7a8e98ea
5 changed files with 13 additions and 19 deletions
|
|
@ -24,5 +24,5 @@ name = "parse_candidates"
|
|||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "parse_candidate_strings_from_files"
|
||||
name = "parse_candidate_strings"
|
||||
harness = false
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue