refactor parse boolish, moved into env_vars and additional convenience
method to read env var and treat as bool
Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
* Add Ruby support (no download support yet)
Currently only pre-existing Rubies are used, although the code will
search for and consider multiple versions. This allows a hook to require
3.4.7 when the default system Ruby is 3.4.6, but RVM (or a similar tool)
has installed 3.4.7. If a suitable Ruby cannot be found, the user is
prompted to install one manually and re-run.
Hooks get an isolated GEM_HOME, based on the hook repository, any
additional_dependencies, and the interpreter version/path. Any Ruby
upgrade would therefore re-install the gems to ensure that stale
versions aren't used. Repository gem dependencies are installed based on
the included gemspec files, combined with the additional_dependencies
field.
* Add pins for CI 'install Ruby' action
* Update setup-ruby pin
* Tweak version parsing
* Tweak env vars
---------
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
* Update GitHub Actions
* Try to speed up windows CI
* Use `leafo/gh-actions-luarocks`
* Fix luarocks install failure
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
* Initial plan
* Optimize hot paths: reduce allocations and add inline hints
- Eliminate duplicate tags_from_path calls in file filtering
- Avoid string allocation for lowercase extensions (fast path for already lowercase)
- Remove unnecessary String clones in environment variable setting
- Add inline hints to hot path functions (TagSet methods, filters, etc.)
- Use lookup table for is_text_char for faster binary detection
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
* Additional optimizations: avoid allocations in hot paths
- Optimize Partitions iterator to use as_os_str().len() instead of to_string_lossy().len()
- Optimize normalize_path on Windows to avoid intermediate String allocation when possible
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
* Revert incorrect filter.rs optimization
The previous change to combine filters was actually less efficient than the original.
The original code correctly filters by filename patterns first, then only calls
tags_from_path on files that pass the filename filter. My change was based on
a misunderstanding - there was no duplication of tags_from_path calls.
Keeping the other optimizations:
- Inline hints on filter functions
- String allocation optimizations in identify.rs
- Environment variable clone removal
- Lookup table for is_text_char
- Partitions iterator optimization
- normalize_path optimization
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
* Optimize IS_TEXT_CHAR to use 256 bits instead of 256 bytes
Changed from [bool; 256] (256 bytes) to [u32; 8] (32 bytes) using bitfield.
This reduces memory footprint by 8x while maintaining O(1) lookup performance.
The lookup now uses bit manipulation:
- table[idx / 32] gets the u32 containing the bit
- (1 << (idx % 32)) creates a mask for the specific bit
- Bitwise AND checks if the bit is set
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
* Lint
* .
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
The profiling isn’t very useful right now - it’s way too sensitive to noise. What we really need is proper benchmarking that runs multiple times to filter out all that noise, like what you get with https://codspeed.io/ or https://bencher.dev/
* perf(hotpath): profile prek run on its own repo
* Combine pr comments
* Fix path
---------
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
```console
❯ hyperfine --warmup 3 'prek run -a trailing-whitespace' './target/release/prek run -a trailing-whitespace'
Benchmark 1: prek run -a trailing-whitespace
Time (mean ± σ): 56.6 ms ± 7.8 ms [User: 28.1 ms, System: 35.7 ms]
Range (min … max): 48.0 ms … 73.0 ms 37 runs
Benchmark 2: ./target/release/prek run -a trailing-whitespace
Time (mean ± σ): 51.0 ms ± 2.6 ms [User: 28.1 ms, System: 35.3 ms]
Range (min … max): 48.1 ms … 61.5 ms 46 runs
Summary
./target/release/prek run -a trailing-whitespace ran
1.11 ± 0.16 times faster than prek run -a trailing-whitespace
```