aboutsummaryrefslogtreecommitdiff
path: root/helix-core/tests
diff options
context:
space:
mode:
authorMichael Davis2023-07-25 18:15:36 +0000
committerBlaž Hrastnik2023-07-27 02:50:19 +0000
commit98ef05d768d287fef2eb790e0a8a6e9a72832e00 (patch)
tree856fa79ea0924834f786a22a76ddfbe188301330 /helix-core/tests
parentf0b877e2588306882f71eaad45a3f3e604885a34 (diff)
Prefer RopeSlice to &Rope in helix_core::syntax
Pascal and I discussed this and we think it's generally better to take a 'RopeSlice' rather than a '&Rope'. The code block rendering function in the markdown component module is a good example for how this can be useful: we can remove an allocation of a rope and instead directly turn a '&str' into a 'RopeSlice' which is very cheap. A change to prefer 'RopeSlice' to '&Rope' whenever the rope isn't modified would be nice, but it would be a very large diff (around 500+ 500-). Starting off with just the syntax functions seems like a nice middle-ground, and we can remove a Rope allocation because of it. Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
Diffstat (limited to 'helix-core/tests')
-rw-r--r--helix-core/tests/indent.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/helix-core/tests/indent.rs b/helix-core/tests/indent.rs
index 409706bb..1dec9989 100644
--- a/helix-core/tests/indent.rs
+++ b/helix-core/tests/indent.rs
@@ -72,9 +72,9 @@ fn test_treesitter_indent(file_name: &str, lang_scope: &str) {
let language_config = loader.language_config_for_scope(lang_scope).unwrap();
let highlight_config = language_config.highlight_config(&[]).unwrap();
- let syntax = Syntax::new(&doc, highlight_config, std::sync::Arc::new(loader)).unwrap();
- let indent_query = language_config.indent_query().unwrap();
let text = doc.slice(..);
+ let syntax = Syntax::new(text, highlight_config, std::sync::Arc::new(loader)).unwrap();
+ let indent_query = language_config.indent_query().unwrap();
for i in 0..doc.len_lines() {
let line = text.line(i);