DirectAllocator: move if > 0 condition above @memcpy

Minor improvement to 3c13aa17 as noted by daurnimator
This commit is contained in:
Andrew Kelley 2019-04-29 13:48:15 -04:00
parent 3c13aa178b
commit 4b6f350369
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -141,8 +141,8 @@ pub const DirectAllocator = struct {
return shrink(allocator, old_mem, old_align, new_size, new_align);
}
const result = try alloc(allocator, new_size, new_align);
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
if (old_mem.len > 0) {
if (old_mem.len != 0) {
@memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len));
_ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len);
}
return result;