From 76a13479d78fc6636ca55b9849f00ec081ef2cc5 Mon Sep 17 00:00:00 2001 From: "Ben L. Titzer" Date: Thu, 15 Aug 2024 12:29:10 -0400 Subject: [PATCH] [lib/util] Use DataWriters.write_range internally in DataWriter itself --- lib/util/DataWriter.v3 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/util/DataWriter.v3 b/lib/util/DataWriter.v3 index 316663841..969d0bc9d 100644 --- a/lib/util/DataWriter.v3 +++ b/lib/util/DataWriter.v3 @@ -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 {