-
Notifications
You must be signed in to change notification settings - Fork 47
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
CompactOsString #244
Comments
You may want to use other inline/small string crates instead for OsString. CompactString assumes the encoding is utf-8 and use that knowledge to store 24 bytes of string inside the 24 bytes CompactString, Without this utf-8 assumption, it will only able to store 16B on 64-bit target, just as other simple inline/small string out there. |
The use case is: read directory, store files names as |
I think that's possible to do, but With all these take into consideration, it seems that Even if @ParkMyCar decided to implement this, it would take quite some time before it's usable. @stepancheg Why not simply use |
Because we already use
Anyway, that is just a feature request. I thought it would be appropriate for |
I'm not the maintainer of this crate and I'm just speaking from my personal experience and understanding of this crate.
IMHO there's nothing wrong using another crate for |
Hey @stepancheg! Thanks for filing an issue, and it's awesome to hear you're using The idea of a
is pretty neat. It would add a slight bit of runtime overhead to determine if it's valid UTF-8, but ideally it would still be a net win since we don't need to heap allocate memory. I know There is extra space in the discriminant of a A |
UTF-8 validation can be done simply by calling It can be further explicitly optimized knowing string data is well aligned like this:
Bonus point is, many os strings get eventually converted to regular strings anyway, and if we already validated it is UTF-8, such conversion would be free.
|
@ParkMyCar If compact_str is going to support CompactOsString, maybe it is a good idea to have CompactUtf16String first and then have a CompactBytes which is for bytes, and all of them sharing the same layout? IMO building CompactOsString will be simpler with these types implemented and it will be more of an incremental improvement instead of having one large PR. |
P.S. If we are considering CompactOsString, then perhaps it is also a good idea to support CStr? |
Add
CompactOsString
, which is inlineOsString
.When working with filesystem, conversion to
String
is not always desirable, and using compact string would be helpful.The text was updated successfully, but these errors were encountered: