Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to unsafely create FastString that is ascii or not #942

Closed
dsherret opened this issue Oct 23, 2024 · 0 comments · Fixed by #943
Closed

Ability to unsafely create FastString that is ascii or not #942

dsherret opened this issue Oct 23, 2024 · 0 comments · Fixed by #943

Comments

@dsherret
Copy link
Member

dsherret commented Oct 23, 2024

There's a perf cost to checking if a string is ascii:

pub const fn from_static(s: &'static str) -> Self {
    if s.is_ascii() {
      Self {
        inner: FastStringInner::StaticAscii(s),
      }
    } else {
      Self {
        inner: FastStringInner::Static(s),
      }
    }
  }

...if this information is known upfront, maybe there could be an API to tell deno_core this unsafely? I'm creating strings from bytes that are &'static [u8] for deno compile and it would be better to store upfront if they're ascii for perf reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant