mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Remove unneeded slicing in strings.clone
This commit is contained in:
@@ -25,7 +25,7 @@ Returns:
|
|||||||
clone :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error {
|
clone :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error {
|
||||||
c := make([]byte, len(s), allocator, loc) or_return
|
c := make([]byte, len(s), allocator, loc) or_return
|
||||||
copy(c, s)
|
copy(c, s)
|
||||||
return string(c[:len(s)]), nil
|
return string(c), nil
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Clones a string safely (returns early with an allocation error on failure)
|
Clones a string safely (returns early with an allocation error on failure)
|
||||||
|
|||||||
Reference in New Issue
Block a user