Use ArrayString for small string optimization in editor AST

This commit is contained in:
Richard Feldman 2020-10-20 20:06:14 -04:00
parent 8d19eb695c
commit b0ad4ec43a
3 changed files with 16 additions and 4 deletions

11
Cargo.lock generated
View File

@ -91,6 +91,15 @@ dependencies = [
"pretty_assertions",
]
[[package]]
name = "arraystring"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d517c467117e1d8ca795bc8cc90857ff7f79790cca0e26f6e9462694ece0185"
dependencies = [
"typenum",
]
[[package]]
name = "arrayvec"
version = "0.5.1"
@ -2358,6 +2367,7 @@ dependencies = [
name = "roc_editor"
version = "0.1.0"
dependencies = [
"arraystring",
"bumpalo",
"env_logger 0.7.1",
"futures",
@ -2389,7 +2399,6 @@ dependencies = [
"roc_unify",
"roc_uniq",
"target-lexicon",
"tokio",
"wgpu",
"wgpu_glyph",
"winit",

View File

@ -28,7 +28,7 @@ im = "14" # im and im-rc should always have the same version!
im-rc = "14" # im and im-rc should always have the same version!
bumpalo = { version = "3.2", features = ["collections"] }
inlinable_string = "0.1"
tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded", "process", "io-driver"] }
arraystring = "0.3.0"
# NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything.
#
# The reason for this fork is that the way Inkwell is designed, you have to use

View File

@ -1,3 +1,4 @@
use arraystring::{typenum::U14, ArrayString};
use inlinable_string::string_ext::StringExt;
use inlinable_string::InlinableString;
use roc_types::subs::Variable;
@ -267,8 +268,10 @@ pub enum Expr2 {
text_bytes: *const u8,
var: Variable,
},
Str {
bytes: [u8; 15],
SmallStr(ArrayString<U14>),
BigStr {
bytes: *const u8,
len: u32,
},
}