-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
- Ustr is hardcoded to allocate 12MB of memory
- Ustr will consume and never free memory unbounded if used with input strings continuously
- Ustr::from_existing can be used to actively mitigate this, but it's not obvious that it's happening in the first place
- Using a wrapper function with a static lifetime requirement can help prevent doing this accidentally
// disallow non-static lifetimes
fn static_ustr(s:&'static str)->Ustr{
ustr(s)
}
- Ustr is never dropped even if a Roblox file is only decoded once and the dom is dropped
- Not a problem for me because I can do it ahead of time, but this put limits on how the library can be used
In my opinion the switch to Ustr is an overall benefit, but perhaps it can be even better with something else.
Ideas:
Perhaps use an owned dictionary. Could be a simple as AHashSet<String>
or a newtype of it. Decode and encode functions accept the dictionary as an argument (mutably for decode), but there are convenient versions which create their own local dictionary if advanced deduplication is not an issue. This means that properties and names can all be &str referencing the dictionary, a total replacement for Ustr with more memory control.
Metadata
Metadata
Assignees
Labels
No labels