mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
runtime: Remove unneeded max(0, ...)
`len` never returns negative numbers, so this was an overcautious expression.
This commit is contained in:
@@ -67,7 +67,7 @@ init_global_temporary_allocator :: proc(size: int, backup_allocator := context.a
|
|||||||
// Prefer the procedure group `copy`.
|
// Prefer the procedure group `copy`.
|
||||||
@builtin
|
@builtin
|
||||||
copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int {
|
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 {
|
if n > 0 {
|
||||||
intrinsics.mem_copy(raw_data(dst), raw_data(src), n*size_of(E))
|
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`.
|
// Prefer the procedure group `copy`.
|
||||||
@builtin
|
@builtin
|
||||||
copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int {
|
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 {
|
if n > 0 {
|
||||||
intrinsics.mem_copy(raw_data(dst), raw_data(src), n)
|
intrinsics.mem_copy(raw_data(dst), raw_data(src), n)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user