From 7e74af32268f9b0783ca94107b0b10d52e4ebe5e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 28 Aug 2018 14:06:30 +0300 Subject: Avoid materializing strings --- crates/libsyntax2/src/yellow/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/libsyntax2/src/yellow/mod.rs') diff --git a/crates/libsyntax2/src/yellow/mod.rs b/crates/libsyntax2/src/yellow/mod.rs index b94c794fe..82eda79d6 100644 --- a/crates/libsyntax2/src/yellow/mod.rs +++ b/crates/libsyntax2/src/yellow/mod.rs @@ -2,6 +2,7 @@ mod builder; mod green; mod red; mod syntax; +mod syntax_text; use std::{ sync::Arc, @@ -12,6 +13,7 @@ pub(crate) use self::{ builder::GreenBuilder, green::GreenNode, red::RedNode, + syntax_text::SyntaxText, }; #[derive(Debug)] @@ -32,6 +34,12 @@ pub struct OwnedRoot(Arc); #[derive(Clone, Copy, Debug)] pub struct RefRoot<'a>(&'a OwnedRoot); // TODO: shared_from_this instead of double indirection +impl<'a> RefRoot<'a> { + fn syntax_root(&self) -> &'a SyntaxRoot { + self.0.syntax_root() + } +} + impl TreeRoot for OwnedRoot { fn borrowed(&self) -> RefRoot { RefRoot(&self) @@ -78,7 +86,7 @@ impl RedPtr { RedPtr(red.into()) } - unsafe fn get<'a>(self, _root: &'a impl TreeRoot) -> &'a RedNode { + unsafe fn get<'a>(self, _root: &'a SyntaxRoot) -> &'a RedNode { &*self.0.as_ptr() } } -- cgit v1.2.3