mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
mem: replace size procedures with constants
This commit is contained in:
+6
-5
@@ -3,6 +3,12 @@ package mem
|
|||||||
import "core:runtime"
|
import "core:runtime"
|
||||||
import "core:intrinsics"
|
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 {
|
set :: proc "contextless" (data: rawptr, value: byte, len: int) -> rawptr {
|
||||||
return runtime.memset(data, i32(value), len)
|
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 {
|
is_power_of_two :: proc "contextless" (x: uintptr) -> bool {
|
||||||
if x <= 0 {
|
if x <= 0 {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
|
|||||||
|
|
||||||
fix_lines(p)
|
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
|
last_line := 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user