mem: replace size procedures with constants

This commit is contained in:
hikari
2022-04-06 18:44:43 +03:00
parent 426a6a9528
commit 698fcb7813
2 changed files with 7 additions and 6 deletions

View File

@@ -3,6 +3,12 @@ package mem
import "core:runtime"
import "core:intrinsics"
Byte :: 1
Kilobyte :: 1024 * Byte
Megabyte :: 1024 * Kilobyte
Gigabyte :: 1024 * Megabyte
Terabyte :: 1024 * Gigabyte
set :: proc "contextless" (data: rawptr, value: byte, len: int) -> rawptr {
return runtime.memset(data, i32(value), len)
}
@@ -192,11 +198,6 @@ any_to_bytes :: proc "contextless" (val: any) -> []byte {
}
kilobytes :: proc "contextless" (x: int) -> int { return (x) * 1024 }
megabytes :: proc "contextless" (x: int) -> int { return kilobytes(x) * 1024 }
gigabytes :: proc "contextless" (x: int) -> int { return megabytes(x) * 1024 }
terabytes :: proc "contextless" (x: int) -> int { return gigabytes(x) * 1024 }
is_power_of_two :: proc "contextless" (x: uintptr) -> bool {
if x <= 0 {
return false

View File

@@ -151,7 +151,7 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
fix_lines(p)
builder := strings.make_builder(0, mem.megabytes(5), p.allocator)
builder := strings.make_builder(0, 5 * mem.Megabyte, p.allocator)
last_line := 0