Skip to content

Adds support for FixedInt and FixedUInt in WriteBuffer#610

Merged
popematt merged 2 commits intoamazon-ion:masterfrom
popematt:fixedint
Oct 16, 2023
Merged

Adds support for FixedInt and FixedUInt in WriteBuffer#610
popematt merged 2 commits intoamazon-ion:masterfrom
popematt:fixedint

Conversation

@popematt
Copy link
Contributor

Issue #, if available:

None

Description of changes:

  • Adds support for FixedInt and FixedUInt in WriteBuffer
  • Also updated WristeBufferTest to only use JUnit 5 dependencies instead of a mix
  • Also added a few more FlexInt and FlexUInt test cases.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
src/com/amazon/ion/impl/bin/WriteBuffer.java 95.52% <100.00%> (+0.22%) ⬆️

... and 1 file with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@zslayton zslayton left a comment

Choose a reason for hiding this comment

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

🚢

@popematt popematt merged commit 3783620 into amazon-ion:master Oct 16, 2023
@popematt popematt deleted the fixedint branch October 16, 2023 22:42
Comment on lines +1408 to +1429
writeByte((byte) value);
if (numBytes > 1) {
writeByte((byte) (value >> 8));
if (numBytes > 2) {
writeByte((byte) (value >> 8 * 2));
if (numBytes > 3) {
writeByte((byte) (value >> 8 * 3));
if (numBytes > 4) {
writeByte((byte) (value >> 8 * 4));
if (numBytes > 5) {
writeByte((byte) (value >> 8 * 5));
if (numBytes > 6) {
writeByte((byte) (value >> 8 * 6));
if (numBytes > 7) {
writeByte((byte) (value >> 8 * 7));
}
}
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As an optimization, we could have fast/slow variants of this too, where we do the current technique when remaining() < numBytes, and otherwise we just write directly into the underlying array.

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.

3 participants