Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jun 25, 2019

Currently when not compiled with Span enabled there is no way to add a segment of an array in a performant manner. ArraySegment is utilized as the alternative to Span in most cases throughout the library and generated code, but Add/Put aren't replicated when 'Span' is not enabled. This is specifically useful for nested flatbuffers where just the used segment of a ByteBuffer can be copied into the parent flatbuffer without an intermediate copy.

Copy link
Collaborator

@aardappel aardappel left a comment

Choose a reason for hiding this comment

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

Generally looks good, thanks! If we could reduce on the code duplication a bit, that be great though.

/// <param name="offset">The offset into this buffer where the copy will end</param>
/// <param name="x">The array to copy data from</param>
/// <returns>The 'start' location of this buffer now, after the copy completed</returns>
public int Put<T>(int offset, ArraySegment<T> x)
Copy link
Collaborator

Choose a reason for hiding this comment

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

a fair bit of code in here is shared with the span case, does it make sense to lift some of it out into common functions, assuming it won't affect performance too much?

@aardappel
Copy link
Collaborator

Related: #5419

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2020

This pull request is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Nov 4, 2020
@github-actions github-actions bot closed this Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants