Skip to content

Commit

Permalink
builtin: more byte => u8
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Apr 15, 2022
1 parent 1e7eb71 commit 7f3b91e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions vlib/builtin/array_d_gcboehm_opt.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -205,15 +205,15 @@ 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
}
}

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++
}

Expand Down
12 changes: 6 additions & 6 deletions vlib/strings/builder.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ 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
}
b << data
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]
}
Expand Down

0 comments on commit 7f3b91e

Please sign in to comment.