fix: Specify the end index in Wkb::buf()#87
fix: Specify the end index in Wkb::buf()#87yutannihilation wants to merge 2 commits intogeorust:mainfrom
Conversation
kylebarron
left a comment
There was a problem hiding this comment.
Hmm. This is a little tricky because, while computing the size should be pretty fast, I'm not sure if we want to require computing the size every time we want to access the buffer.
Possible options are:
- Document that
bufwill overshoot this geometry's buffer in the case it's part of a geometry collection - Call
size()every time inside ofbufand subset the buffer - Cache
size()as part of the struct
Any thoughts @Kontinuation as you were the one to expose this API in #85?
|
Thanks for the comment. Yeah, it's not obvious which option is the best... I'd vote for calling For more context, I found this problem when I tried to use |
|
How about adding |
|
The proposed patch changes the semantics of The ideal approach is to remove |
|
This is my attempt to reimplement |
|
Oh, thanks, it looks way better than my approach. I actually wanted the |
CHANGES.mdif knowledge of this change could be valuable to users.Fix #86
I was hoping to specify the end index in
Wkb::try_new()or inGeometryCollection::try_new(), but I found it difficult because we can call.size()only after we construct the struct. So, this pull request chooses to do it inbuf(), in the assumption that calling.size()is cheap and.buf()is probably called less frequently thantry_new().