diff --git a/crates/turbo-tasks/src/rcstr.rs b/crates/turbo-tasks/src/rcstr.rs index 715a5a0e79f44..65c946ffd7b3b 100644 --- a/crates/turbo-tasks/src/rcstr.rs +++ b/crates/turbo-tasks/src/rcstr.rs @@ -4,15 +4,19 @@ use std::{ fmt::{Debug, Display}, ops::Deref, path::{Path, PathBuf}, - sync::Arc, }; use serde::{Deserialize, Serialize}; +use triomphe::Arc; use turbo_tasks_hash::{DeterministicHash, DeterministicHasher}; use crate::debug::{ValueDebugFormat, ValueDebugFormatString}; -/// This type exists to allow swapping out the underlying string type easily. +/// A reference counted [`String`], similar to [`Arc`][std::sync::Arc]. +/// +/// This type is intentionally opaque to allow for optimizations to the +/// underlying representation. Future implementations may use inline +/// representations or interning. // // If you want to change the underlying string type to `Arc`, please ensure that you profile // performance. The current implementation offers very cheap `String -> RcStr -> String`, meaning we diff --git a/crates/turbopack-ecmascript/src/parse.rs b/crates/turbopack-ecmascript/src/parse.rs index 604b65aa82163..4bcf95214499c 100644 --- a/crates/turbopack-ecmascript/src/parse.rs +++ b/crates/turbopack-ecmascript/src/parse.rs @@ -419,7 +419,8 @@ async fn parse_content( } else { None }; - let messages = Some(messages.unwrap_or_else(|| vec![fm.src.clone().into()])); + let messages = + Some(messages.unwrap_or_else(|| vec![String::clone(&fm.src).into()])); return Ok(ParseResult::Unparseable { messages }); }