diff --git a/.changelog/oxide-elixir-sigil-scan.md b/.changelog/oxide-elixir-sigil-scan.md new file mode 100644 index 000000000000..3138f6685078 --- /dev/null +++ b/.changelog/oxide-elixir-sigil-scan.md @@ -0,0 +1,3 @@ +### Fixed + +- Improve performance of scanning Elixir files (e.g. `.heex` and `.ex`) diff --git a/crates/oxide/src/extractor/pre_processors/elixir.rs b/crates/oxide/src/extractor/pre_processors/elixir.rs index 7737a6b2d1ae..eae0cbd62e93 100644 --- a/crates/oxide/src/extractor/pre_processors/elixir.rs +++ b/crates/oxide/src/extractor/pre_processors/elixir.rs @@ -1,6 +1,7 @@ use crate::cursor; use crate::extractor::bracket_stack::BracketStack; use crate::extractor::pre_processors::pre_processor::PreProcessor; +use bstr::ByteSlice; #[derive(Debug, Default)] pub struct Elixir; @@ -14,7 +15,10 @@ impl PreProcessor for Elixir { while cursor.pos < content.len() { // Look for a sigil marker if cursor.curr() != b'~' { - cursor.advance(); + match content[cursor.pos..].find_byte(b'~') { + Some(offset) => cursor.pos += offset, + None => break, + } continue; }