fix small string handling

This commit is contained in:
Brendan Hansknecht 2024-12-10 20:29:46 -08:00
parent 5fbf8f5b1c
commit 5d0947960c
No known key found for this signature in database
GPG key ID: A199D0660F95F948

View file

@ -780,7 +780,7 @@ impl RocRefcounted for SendSafeRocStr {
impl Clone for SendSafeRocStr {
fn clone(&self) -> Self {
if self.0.is_readonly() {
if self.0.is_readonly() || self.0.is_small_str() {
SendSafeRocStr(self.0.clone())
} else {
// To keep self send safe, this must copy.
@ -851,7 +851,7 @@ impl From<RocStr> for ReadOnlyRocStr {
if s.is_unique() {
unsafe { s.set_readonly() };
}
if s.is_readonly() {
if s.is_readonly() || s.is_small_str() {
ReadOnlyRocStr(s)
} else {
// This is not readonly or unique, do a deep copy.