authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-01-10 15:03:51+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-01-10 15:03:51+11:00
log03e1241b8828ff9e106d46862ca36fcd75cdc3c4
tree4c2501da8684ab53fb4297d42f177e29b693f2bb
parent6fb636050fd0fac9615e6014316b8d42d8370f42
signature Commit is signed but in an unrecognized format.

std: avoid an allocation in inner loop


1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/child_process.zig+4-4
...@@ -634,12 +634,12 @@ pub const ChildProcess = struct {...@@ -634,12 +634,12 @@ pub const ChildProcess = struct {
634634
635 var it = mem.tokenize(PATH, ";");635 var it = mem.tokenize(PATH, ";");
636 retry: while (it.next()) |search_path| {636 retry: while (it.next()) |search_path| {
637 const path_no_ext = try fs.path.join(self.allocator, &[_][]const u8{ search_path, app_name });
638 defer self.allocator.free(path_no_ext);
639
637 var ext_it = mem.tokenize(PATHEXT, ";");640 var ext_it = mem.tokenize(PATHEXT, ";");
638 while (ext_it.next()) |app_ext| {641 while (ext_it.next()) |app_ext| {
639 const app_basename = try mem.concat(self.allocator, u8, &[_][]const u8{ app_name, app_ext });642 const joined_path = try mem.concat(self.allocator, u8, &[_][]const u8{ path_no_ext, app_ext });
640 defer self.allocator.free(app_basename);
641
642 const joined_path = try fs.path.join(self.allocator, &[_][]const u8{ search_path, app_basename });
643 defer self.allocator.free(joined_path);643 defer self.allocator.free(joined_path);
644644
645 const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, joined_path);645 const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, joined_path);