Skip to content

Conversation

MaxGraey
Copy link
Member

No description provided.

var buffer = this.buffer;
var byteOffset = this.byteOffset;
var len = this.length;
start = start < 0 ? max(len + start, byteOffset >> alignof<T>()) : min(start, len);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about lower and upper limits. Need more tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible to ignore byteOffset up to the point where the memory.fill operation is used, like with a normal array. That's just the offset into the backing buffer when accessing it internally.

memory.fill(
changetype<usize>(buffer) + start + byteOffset + AB_HEADER_SIZE,
<u8>value,
<usize>(end - start)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's necessary to make sure that end >= start, otherwise this might overflow and copy like all the memory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. fill(0xff, 1, 0) on an Uint8Array: start = 1, end = 0, <usize>(0 - 1) = 0xffffffff

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah makes sense

@dcodeIO
Copy link
Member

dcodeIO commented Oct 25, 2018

Looking good with the conflicts resolved

@dcodeIO dcodeIO merged commit 83fa121 into AssemblyScript:master Oct 26, 2018
@dcodeIO
Copy link
Member

dcodeIO commented Oct 26, 2018

Thank you!

@MaxGraey MaxGraey deleted the TypedArray#fill branch October 26, 2018 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants