Unique vectors#550
Conversation
|
We might want to add a few more apis (cutting an array short and dropping the the rest of the array), or extending an array. |
anfelor
left a comment
There was a problem hiding this comment.
Thanks @TimWhiting, this looks a lot friendlier than my draft! I made a few minor comments regarding naming of variables and documentation.
I worry a bit that the unsafe surface area is quite large still. I think we can probably pay for two is-unique checks per iteration of map (given that the second can be well-predicted). Then we can make this API more clean by incorporating the copy calls into unsafe-assign and unsafe-idx-own.
Yes, that would be fun! I think we could also support |
I think these sorts of APIs are maybe best left to a resizeable vector type, which could hold on to the length like you mention and have a resize policy for add / extending the vector as well. What do you think? |
2de1419 to
d7dffea
Compare
|
I've found a bug with this. Specifically, it behaves poorly with exceptions. Note that this doesn't affect all of the other vector functions, just the mutation of vector elements in local variables (i.e. I think we can still do efficient update of mutable variables, but it will require some runtime changes. Turning this to draft for now, until we can discuss this, though I think we should probably move ahead with the other changes which are independent from the local variable change. |
94ff897 to
4e9aaae
Compare
…d some documentation
… vector variables
da2e1dc to
03f181e
Compare
Addresses #544
@anfelor can you take a look at this?
I added a few public apis and a few private helpers.
Public:
setupdateupdatefor local variable vectorsThe most important function is the
copyfunction, which ensures that the vector is unique prior to applying any mutation operations. For many cases we would expect it to be unique.I've updated this to use PR #716 here: TimWhiting@b0ef63b