-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
WINDOWS: make env.jl and file.jl unicode-compliant for #4240 #7008
Conversation
// hidden 0 terminator for all byte arrays | ||
tot++; | ||
if (elsz <= sizeof(void*) && ndims == 1) { | ||
// hidden 0 terminator for all small-element arrays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeffBezanson is this acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No; sizeof(void*)
is big enough to hold an Int64
or Float64
, so this amounts to over-allocating essentially every array. Due to alignment this will actually add 16 bytes, which is a lot of overhead if you have lots of small arrays. The size of our array metadata (64 bytes) is already killer for lots of small objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please suggest another approach then
Perhaps ccall could push! a hidden zero on every array, and set a flag bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know; this is a very hard problem. Calling push! internally is a non-starter; it's very expensive, and ccall might not always have access to the array object itself. Maybe the UTF16String constructor can handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or adding a 0 if elsz <= 2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exactly do we need this?
For strlen If utf16string is going to handle this in Julia, then perhaps everything should. This really just feels too magical, and therefore problematic, since the user has so many avenues for making strings. |
We have to think in detail about what cases we can and can't handle. For example, if you allocate data in C and wrap it with |
It seems reasonable to me to handle this in |
No description provided.