aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2023-05-15 20:40:47 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2023-05-15 20:52:07 +0200
commit2ab6de8ee41aeb7c71f36f04a3a2941a711c6dbe (patch)
tree202b9a1169ff243b94b1b248b51156a8e588b78e /core/encoding
parent6e4fab19a28ebc3d7bd9af76ffccfcc64b93ac9b (diff)
fix hex.encode and add tests for the package
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/hex/hex.odin8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/encoding/hex/hex.odin b/core/encoding/hex/hex.odin
index 8d0102c02..ef0bab1d0 100644
--- a/core/encoding/hex/hex.odin
+++ b/core/encoding/hex/hex.odin
@@ -4,11 +4,11 @@ import "core:strings"
encode :: proc(src: []byte, allocator := context.allocator) -> []byte #no_bounds_check {
dst := make([]byte, len(src) * 2, allocator)
- for i := 0; i < len(src); i += 1 {
+ for i, j := 0, 0; i < len(src); i += 1 {
v := src[i]
- dst[i] = HEXTABLE[v>>4]
- dst[i+1] = HEXTABLE[v&0x0f]
- i += 2
+ dst[j] = HEXTABLE[v>>4]
+ dst[j+1] = HEXTABLE[v&0x0f]
+ j += 2
}
return dst