Skip to content

Commit afaaf73

Browse files
committed
shrink Strings too
1 parent faaace5 commit afaaf73

File tree

1 file changed

+12
-11
lines changed
  • turbopack/crates/turbo-tasks-fs/src

1 file changed

+12
-11
lines changed

turbopack/crates/turbo-tasks-fs/src/rope.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,14 @@ impl Rope {
121121
impl From<Vec<u8>> for Rope {
122122
fn from(mut bytes: Vec<u8>) -> Self {
123123
bytes.shrink_to_fit();
124-
let bytes: Bytes = bytes.into();
125-
// We can't have an InnerRope which contains an empty Local section.
126-
if bytes.is_empty() {
127-
Default::default()
128-
} else {
129-
Rope {
130-
length: bytes.len(),
131-
data: InnerRope(Arc::from([Local(bytes)])),
132-
}
133-
}
124+
Rope::from(Bytes::from(bytes))
125+
}
126+
}
127+
128+
impl From<String> for Rope {
129+
fn from(mut bytes: String) -> Self {
130+
bytes.shrink_to_fit();
131+
Rope::from(Bytes::from(bytes))
134132
}
135133
}
136134

@@ -325,7 +323,10 @@ impl Uncommitted {
325323
match mem::take(self) {
326324
Self::None => None,
327325
Self::Static(s) => Some(s.into()),
328-
Self::Owned(v) => Some(v.into()),
326+
Self::Owned(mut v) => {
327+
v.shrink_to_fit();
328+
Some(v.into())
329+
}
329330
}
330331
}
331332
}

0 commit comments

Comments
 (0)