causal-agent / scraper

HTML parsing and querying with CSS selectors
https://docs.rs/scraper
ISC License
1.81k stars 100 forks source link

build(deps): fix unchecked lock and update deps #107

Closed j-mendez closed 1 year ago

j-mendez commented 1 year ago
  1. build(deps): update cssparser@0.29.6 and selector@0.24.0 (mem reduction, perf increase, and css3 syntax fixes )
  2. fix missing Cargo.lock file
  3. add lazy evaluation classes
j-mendez commented 1 year ago

@cfvescovo @cfvescovo .or is evaluated regardless if it is true. For this situation we do not need to create a new hashset eagerly and can move it lazily.

We can use or for this block in the element_ref and it makes sense since we want this to be fast during this execution.

    fn is_root(&self) -> bool {
        self.parent()
            .map_or_else(|| false, |parent| parent.value().is_document())
    }
cfvescovo commented 1 year ago

I know but Rust's collections generally don't allocate on initialisation, so an eager String::new() or HashMap::new() doesn't really matter

cfvescovo commented 1 year ago

However I see your point so I removed my comment

j-mendez commented 1 year ago

I know but Rust's collections generally don't allocate on initialisation, so an eager String::new() or HashMap::new() doesn't really matter

We want to leave the stack alone for this and should be fine to move it lazy. I can revert the change to keep it just with the build deps.

cfvescovo commented 1 year ago

I was referencing this: https://stackoverflow.com/a/73785382

cfvescovo commented 1 year ago

I know but Rust's collections generally don't allocate on initialisation, so an eager String::new() or HashMap::new() doesn't really matter

We want to leave the stack alone for this and should be fine to move it lazy. I can revert the change to keep it just with the build deps.

Keep your changes, I see your point. It won't make much of a difference but ok.

j-mendez commented 1 year ago

@cfvescovo thank you for the fast replies - fixing the format issues now.

cfvescovo commented 1 year ago

Cargo fmt is complaining, rerun the formatter

cfvescovo commented 1 year ago

@j-mendez thank you!