1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: make bools take up a single byte, not 4 (#9352)

This commit is contained in:
spaceface
2021-03-18 15:23:29 +01:00
committed by GitHub
parent 4ae2c22c18
commit 624c1f3bcf
4 changed files with 13 additions and 11 deletions

View File

@ -260,19 +260,19 @@ fn map_eq_string(a voidptr, b voidptr) bool {
}
fn map_eq_int_1(a voidptr, b voidptr) bool {
return unsafe { *&byte(a) == *&byte(b) }
return unsafe { C.memcmp(a, b, 1) == 0 }
}
fn map_eq_int_2(a voidptr, b voidptr) bool {
return unsafe { *&u16(a) == *&u16(b) }
return unsafe { C.memcmp(a, b, 2) == 0 }
}
fn map_eq_int_4(a voidptr, b voidptr) bool {
return unsafe { *&u32(a) == *&u32(b) }
return unsafe { C.memcmp(a, b, 4) == 0 }
}
fn map_eq_int_8(a voidptr, b voidptr) bool {
return unsafe { *&u64(a) == *&u64(b) }
return unsafe { C.memcmp(a, b, 8) == 0 }
}
fn map_clone_string(dest voidptr, pkey voidptr) {
@ -284,25 +284,25 @@ fn map_clone_string(dest voidptr, pkey voidptr) {
fn map_clone_int_1(dest voidptr, pkey voidptr) {
unsafe {
*&byte(dest) = *&byte(pkey)
C.memcpy(dest, pkey, 1)
}
}
fn map_clone_int_2(dest voidptr, pkey voidptr) {
unsafe {
*&u16(dest) = *&u16(pkey)
C.memcpy(dest, pkey, 2)
}
}
fn map_clone_int_4(dest voidptr, pkey voidptr) {
unsafe {
*&u32(dest) = *&u32(pkey)
C.memcpy(dest, pkey, 4)
}
}
fn map_clone_int_8(dest voidptr, pkey voidptr) {
unsafe {
*&u64(dest) = *&u64(pkey)
C.memcpy(dest, pkey, 8)
}
}