Skip to content

Commit 6286f26

Browse files
committed
Revert "passthrough the extension to the Extractor itself"
This reverts commit 4ff21a3.
1 parent 1134ddf commit 6286f26

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

crates/oxide/src/extractor/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,15 @@ impl fmt::Display for Extracted<'_> {
5656
#[derive(Debug)]
5757
pub struct Extractor<'a> {
5858
cursor: cursor::Cursor<'a>,
59-
extension: Option<&'a str>,
6059

6160
css_variable_machine: CssVariableMachine,
6261
candidate_machine: CandidateMachine,
6362
}
6463

6564
impl<'a> Extractor<'a> {
66-
pub fn new(input: &'a [u8], extension: Option<&'a str>) -> Self {
65+
pub fn new(input: &'a [u8]) -> Self {
6766
Self {
6867
cursor: cursor::Cursor::new(input),
69-
extension,
7068

7169
css_variable_machine: Default::default(),
7270
candidate_machine: Default::default(),
@@ -210,7 +208,7 @@ mod tests {
210208
}
211209

212210
fn extract_sorted_candidates(input: &str) -> Vec<&str> {
213-
let mut machine = Extractor::new(input.as_bytes(), None);
211+
let mut machine = Extractor::new(input.as_bytes());
214212
let mut actual = machine
215213
.extract()
216214
.iter()
@@ -224,7 +222,7 @@ mod tests {
224222
}
225223

226224
fn extract_sorted_css_variables(input: &str) -> Vec<&str> {
227-
let mut machine = Extractor::new(input.as_bytes(), None);
225+
let mut machine = Extractor::new(input.as_bytes());
228226
let mut actual = machine
229227
.extract()
230228
.iter()
@@ -289,12 +287,12 @@ mod tests {
289287
let input = include_bytes!("../fixtures/example.html");
290288

291289
let throughput = Throughput::compute(iterations, input.len(), || {
292-
let mut extractor = Extractor::new(input, None);
290+
let mut extractor = Extractor::new(input);
293291
_ = black_box(extractor.extract());
294292
});
295293
eprintln!("Extractor throughput: {:}", throughput);
296294

297-
let mut extractor = Extractor::new(input, None);
295+
let mut extractor = Extractor::new(input);
298296
let start = std::time::Instant::now();
299297
_ = black_box(extractor.extract().len());
300298
let end = start.elapsed();

crates/oxide/src/extractor/pre_processors/pre_processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub trait PreProcessor: Sized + Default {
3333
let processor = Self::default();
3434
let transformed = processor.process(input);
3535

36-
let extracted = Extractor::new(&transformed, None).extract();
36+
let extracted = Extractor::new(&transformed).extract();
3737

3838
// Extract all candidates and css variables.
3939
let candidates = extracted

crates/oxide/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tailwindcss_oxide::extractor::{Extracted, Extractor};
55
use tailwindcss_oxide::throughput::Throughput;
66

77
fn run_full_extractor(input: &[u8]) -> Vec<&[u8]> {
8-
Extractor::new(input, None)
8+
Extractor::new(input)
99
.extract()
1010
.into_iter()
1111
.map(|x| match x {

crates/oxide/src/scanner/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl Scanner {
327327
&mut self,
328328
changed_content: ChangedContent,
329329
) -> Vec<(String, usize)> {
330-
let (content, extension) = read_changed_content(changed_content).unwrap_or_default();
330+
let content = read_changed_content(changed_content).unwrap_or_default();
331331
let original_content = &content;
332332

333333
// Workaround for legacy upgrades:
@@ -337,7 +337,7 @@ impl Scanner {
337337
let content = content.replace("-[]", "XYZ");
338338
let offset = content.as_ptr() as usize;
339339

340-
let mut extractor = Extractor::new(&content[..], Some(&extension));
340+
let mut extractor = Extractor::new(&content[..]);
341341

342342
extractor
343343
.extract()
@@ -364,7 +364,7 @@ impl Scanner {
364364
}
365365
}
366366

367-
fn read_changed_content(c: ChangedContent) -> Option<(Vec<u8>, String)> {
367+
fn read_changed_content(c: ChangedContent) -> Option<Vec<u8>> {
368368
let (content, extension) = match c {
369369
ChangedContent::File(file, extension) => match std::fs::read(&file) {
370370
Ok(content) => (content, extension),
@@ -377,7 +377,7 @@ fn read_changed_content(c: ChangedContent) -> Option<(Vec<u8>, String)> {
377377
ChangedContent::Content(contents, extension) => (contents.into_bytes(), extension),
378378
};
379379

380-
Some((pre_process_input(&content, &extension), extension))
380+
Some(pre_process_input(&content, &extension))
381381
}
382382

383383
pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
@@ -398,7 +398,7 @@ pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
398398
}
399399

400400
#[tracing::instrument(skip_all)]
401-
fn read_all_files(changed_content: Vec<ChangedContent>) -> Vec<(Vec<u8>, String)> {
401+
fn read_all_files(changed_content: Vec<ChangedContent>) -> Vec<Vec<u8>> {
402402
event!(
403403
tracing::Level::INFO,
404404
"Reading {:?} file(s)",
@@ -412,16 +412,16 @@ fn read_all_files(changed_content: Vec<ChangedContent>) -> Vec<(Vec<u8>, String)
412412
}
413413

414414
#[tracing::instrument(skip_all)]
415-
fn parse_all_blobs(blobs: Vec<(Vec<u8>, String)>) -> Vec<String> {
415+
fn parse_all_blobs(blobs: Vec<Vec<u8>>) -> Vec<String> {
416416
let mut result: Vec<_> = blobs
417417
.par_iter()
418-
.flat_map(|(blob, extension)| blob.par_split(|x| *x == b'\n').map(move |x| (x, extension)))
419-
.filter_map(|(blob, extension)| {
418+
.flat_map(|blob| blob.par_split(|x| *x == b'\n'))
419+
.filter_map(|blob| {
420420
if blob.is_empty() {
421421
return None;
422422
}
423423

424-
let extracted = crate::extractor::Extractor::new(blob, Some(extension)).extract();
424+
let extracted = crate::extractor::Extractor::new(blob).extract();
425425
if extracted.is_empty() {
426426
return None;
427427
}

0 commit comments

Comments
 (0)