Directly intern values from an input str slice #135
Labels
No labels
A-build
A-cli
A-core
A-design
A-edn
A-ffi
A-query
A-sdk
A-sdk-android
A-sdk-ios
A-sync
A-transact
A-views
A-vocab
P-Android
P-desktop
P-iOS
bug
correctness
dependencies
dev-ergonomics
discussion
documentation
duplicate
enhancement
enquiry
good first bug
good first issue
help wanted
hygiene
in progress
invalid
question
ready
size
speed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/mentat#135
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Each of our structs keeps an owned value.
To avoid excessive duplication, we wish to use
Rc
here to avoid having thousands of duplicated strings.But even with
InternSet
andRc
, we end up creating garbage:&str
.Keyword
, which clones the slice into a newString
.Keyword
(wrapped in anRc
) inInternSet
, which drops the new keyword and returns the existing one.It would be good to come up with a strategy for going straight from the
&str
to theRc<Keyword>
. This might be a factory method provided to the parser. It might be an extended EDN representation (edn::Value<InternedString>
?). It might be a kind ofBorrow
hook.It's also possible that LLVM will optimize away that allocation… but I doubt it, particularly in the way we currently work (which means collecting all of these
Keyword
s and getting rid of the duplicates later).This ticket involves a fair amount of good Rust judgment, so it's not suitable for beginners.