Conversation
|
Can this maybe reuse the Uint8Array implementation, like in |
|
@dcodeIO We could reuse the parent class's version. All we have to do is change the rtId value. let result = super.subarray(...);
let block = changetype<BLOCK>(changetype<usize>(result) - BLOCK_OFFSET); // whatever this is
block.rtId = idOf<Buffer>();
return result; |
|
Best solution would just be to use the macro in the std lib but it's not exported. |
|
Unless there are any problems with this implementation, can we pull this? |
|
I will leave this as implemented for now because it's technically faster than: let out = super.subarray(start, end);
changetype<BLOCK>(changetype<usize>(out) - BLOCK_OFFSET).rtId = idof<Buffer>();
return out; |
|
How about use: public subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Buffer {
return SUBARRAY<Buffer, u8>(this, begin, end);
}And make |
|
Or even better move all typedarray's macros to new |
|
@MaxGraey That would be nice, but I can't use the |
|
Seems fine this way. |
|
If AssemblyScript/assemblyscript#740 pulls, then I will refactor the current implementation to contain the utility functions. |
Original
.subarray()implementation does not returnBuffer. It returnsUint8Array.Copied and optimized for our purposes from the
SUBARRAYmacro. Any problems? @dcodeIO