From 61f9fb72327fcbc0c1c5b130f5e416b5c5dd9d00 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Fri, 13 Jun 2025 12:09:10 -0400 Subject: [PATCH] runtime: Remove unneeded `max(0, ...)` `len` never returns negative numbers, so this was an overcautious expression. --- base/runtime/core_builtin.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin index bc201b6e1..e2ba14f3a 100644 --- a/base/runtime/core_builtin.odin +++ b/base/runtime/core_builtin.odin @@ -67,7 +67,7 @@ init_global_temporary_allocator :: proc(size: int, backup_allocator := context.a // Prefer the procedure group `copy`. @builtin copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int { - n := max(0, min(len(dst), len(src))) + n := min(len(dst), len(src)) if n > 0 { intrinsics.mem_copy(raw_data(dst), raw_data(src), n*size_of(E)) } @@ -80,7 +80,7 @@ copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int { // Prefer the procedure group `copy`. @builtin copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int { - n := max(0, min(len(dst), len(src))) + n := min(len(dst), len(src)) if n > 0 { intrinsics.mem_copy(raw_data(dst), raw_data(src), n) }