Browse Source

mem: replace size procedures with constants

hikari 3 years ago
parent
commit
698fcb7813
2 changed files with 7 additions and 6 deletions
  1. 6 5
      core/mem/mem.odin
  2. 1 1
      core/odin/printer/printer.odin

+ 6 - 5
core/mem/mem.odin

@@ -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

+ 1 - 1
core/odin/printer/printer.odin

@@ -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