Skip to content

Commit

Permalink
[lib/util] Use DataWriters.write_range internally in DataWriter itself
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Aug 15, 2024
1 parent 6c1fd09 commit 76a1347
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/util/DataWriter.v3
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ class DataWriter {
// Write a 16-bit little-endian integer.
def put_b16(data: int) -> this {
var a = acquire(2);
a[0] = byte.view(data);
a[1] = byte.view(data >> 8);
DataWriters.write_range_i16(a, i16.view(data));
}
// Write a 32-bit little-endian integer.
def put_b32(data: int) -> this {
var a = acquire(4);
a[0] = byte.view(data);
a[1] = byte.view(data >> 8);
a[2] = byte.view(data >> 16);
a[3] = byte.view(data >> 24);
DataWriters.write_range_i32(a, data);
}
// Write a 64-bit little-endian integer.
def put_b64(data: long) -> this {
put_b32(int.view(data));
put_b32(int.view(data >> 32));
var a = acquire(8);
DataWriters.write_range_i64(a, data);
}
// Write a 16-bit big-endian integer.
def put_b16be(data: int) -> this {
Expand Down

0 comments on commit 76a1347

Please sign in to comment.