-
Notifications
You must be signed in to change notification settings - Fork 30
decode png ptr+len api #434
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
Conversation
|
why not just change signature to openArray[char]? |
|
@SolitudeSF I could do openArray, but that has its own issues.
In the PNG case openArray would just fine as written, however ->
I could wrap that in an openArray, but what is the point? I get openArray is useful for seq | array procs, but because I can't treat it like a "thing" it ends up no being worth using in many of my cases thus far. Why wrap a ptr + len from the OS in something new for no reason? Same for opening a memory-mapped Zip Archive. If have a ptr + len already, why wrap it to decode a PNG from inside the archive (and then have to unwrap it or make a new one for ptr+len in the larger buffer)? |
|
Just adding that I have used openArray over here https://github.com/guzba/zippy/blob/master/src/zippy/inflate.nim#L17, I just find it doesn't fit well all the time. |
|
im not advising for it as a single unifying api, im saying that its a straight upgrade from just string. |
|
i would even go as far to say that |
|
Ah, I do see your point for That shouldn't be a reason not to make things better but it is a concern I'd need to overcome myself. A small but more practical difference that is a sort of gotcha I've run into before: This is easy with a string: decodePng(data.cstring, data.len)Whereas you need to be careful with openArray: if data.len > 0:
decodePng(data[0].unsafeAddr, data.len)
else:
# failAll of our repos will evolve so who knows, maybe we'll go all openArray before long, it's not like we can't ever switch to it. I don't currently see it as the most pressing issue though. |
this enables windy to not need to copyMem before decoding an image here: https://github.com/treeform/windy/blob/master/src/windy/platforms/macos/platform.nim#L962