unicode-rs / unicode-normalization

Unicode Normalization forms according to UAX#15 rules
https://unicode-rs.github.io/unicode-normalization
Other
160 stars 42 forks source link

collect optimization ? #99

Open wiiznokes opened 7 months ago

wiiznokes commented 7 months ago

I want to use this crate to normalize a search, so i have concern about the performance of .collect::<String>.

Is there a way to reuse the previous value, when possible ?

When i try .collect::<Cow<str>>, i always see Owned("...") in the debugger.

Manishearth commented 7 months ago

.collect() is a trait method so I don't think it can be optimized that way, but I'm open to there being other APIs for it if it doesn't end up being too complicated