From 7f3b91e6883193371cd88c8ad3599bdd3e02b140 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 15 Apr 2022 14:10:11 +0300 Subject: [PATCH] builtin: more byte => u8 --- vlib/builtin/array_d_gcboehm_opt.v | 10 +++++----- vlib/strings/builder.js.v | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vlib/builtin/array_d_gcboehm_opt.v b/vlib/builtin/array_d_gcboehm_opt.v index 27f92cde69..d40ed47897 100644 --- a/vlib/builtin/array_d_gcboehm_opt.v +++ b/vlib/builtin/array_d_gcboehm_opt.v @@ -105,9 +105,9 @@ fn (a array) repeat_to_depth_noscan(count int, depth int) array { for i in 0 .. count { if depth > 0 { ary_clone := unsafe { a.clone_to_depth_noscan(depth) } - unsafe { vmemcpy(arr.get_unsafe(i * a.len), &byte(ary_clone.data), a.len * a.element_size) } + unsafe { vmemcpy(arr.get_unsafe(i * a.len), &u8(ary_clone.data), a.len * a.element_size) } } else { - unsafe { vmemcpy(arr.get_unsafe(i * a.len), &byte(a.data), a.len * a.element_size) } + unsafe { vmemcpy(arr.get_unsafe(i * a.len), &u8(a.data), a.len * a.element_size) } } } } @@ -167,7 +167,7 @@ fn (mut a array) pop_noscan() voidptr { } } new_len := a.len - 1 - last_elem := unsafe { &byte(a.data) + new_len * a.element_size } + last_elem := unsafe { &u8(a.data) + new_len * a.element_size } a.len = new_len // Note: a.cap is not changed here *on purpose*, so that // further << ops on that array will be more efficient. @@ -205,7 +205,7 @@ fn (a &array) clone_to_depth_noscan(depth int) array { return arr } else { if !isnil(a.data) { - unsafe { vmemcpy(&byte(arr.data), a.data, a.cap * a.element_size) } + unsafe { vmemcpy(&u8(arr.data), a.data, a.cap * a.element_size) } } return arr } @@ -213,7 +213,7 @@ fn (a &array) clone_to_depth_noscan(depth int) array { fn (mut a array) push_noscan(val voidptr) { a.ensure_cap_noscan(a.len + 1) - unsafe { vmemcpy(&byte(a.data) + a.element_size * a.len, val, a.element_size) } + unsafe { vmemcpy(&u8(a.data) + a.element_size * a.len, val, a.element_size) } a.len++ } diff --git a/vlib/strings/builder.js.v b/vlib/strings/builder.js.v index 4df19c2e82..22909bb782 100644 --- a/vlib/strings/builder.js.v +++ b/vlib/strings/builder.js.v @@ -12,22 +12,22 @@ pub mut: initial_size int = 1 }*/ -pub type Builder = []byte +pub type Builder = []u8 pub fn new_builder(initial_size int) Builder { - return []byte{cap: initial_size} + return []u8{cap: initial_size} } [deprecated: 'Use write_byte() instead'] -pub fn (mut b Builder) write_b(data byte) { +pub fn (mut b Builder) write_b(data u8) { b << data } -pub fn (mut b Builder) write_byte(data byte) { +pub fn (mut b Builder) write_byte(data u8) { b << data } -pub fn (mut b Builder) write(data []byte) ?int { +pub fn (mut b Builder) write(data []u8) ?int { if data.len == 0 { return 0 } @@ -35,7 +35,7 @@ pub fn (mut b Builder) write(data []byte) ?int { return data.len } -pub fn (b &Builder) byte_at(n int) byte { +pub fn (b &Builder) byte_at(n int) u8 { unsafe { return b[n] }