From ad471452ba6fbbf91ad566dc4bdf1033a7281811 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 18 May 2018 16:19:35 +1000 Subject: Make `Directory::path` a `Cow`. Because we create a lot of these in the macro parser, but only very rarely modify them. This speeds up some html5ever runs by 2--3%. --- src/libsyntax/parse/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse/mod.rs') diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index f26a6a53074..0abedb99bd0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -23,6 +23,7 @@ use symbol::Symbol; use tokenstream::{TokenStream, TokenTree}; use diagnostics::plugin::ErrorMap; +use std::borrow::Cow; use std::collections::HashSet; use std::iter; use std::path::{Path, PathBuf}; @@ -89,8 +90,8 @@ impl ParseSess { } #[derive(Clone)] -pub struct Directory { - pub path: PathBuf, +pub struct Directory<'a> { + pub path: Cow<'a, Path>, pub ownership: DirectoryOwnership, } -- cgit 1.4.1-3-g733a5