mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-18 20:40:28 +00:00
mem: replace size procedures with constants
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user