diff options
author | Edward Thomson <ethomson@microsoft.com> | 2014-10-11 21:38:22 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2014-10-13 13:36:20 -0400 |
commit | 6a26488f8b162ad0b91a8ad52a6ed380939cdd2f (patch) | |
tree | 1411de1d7b4be452df57cf60b8c3c45c0251720a | |
parent | 5e2cf2ca2c639b142776709df83b7fcbae0e4a70 (diff) | |
download | libgit2-6a26488f8b162ad0b91a8ad52a6ed380939cdd2f.tar.gz |
Don't copy buffer in checkout unless needed
-rw-r--r-- | src/checkout.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/checkout.c b/src/checkout.c index 06569dc7f..8aaf8c5ae 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -1813,14 +1813,17 @@ static int checkout_write_merge( goto done; if (!data->opts.disable_filters) { - if ((error = git_buf_put(&in_data, result.ptr, result.len)) < 0 || - (error = git_filter_list_load(&fl, data->repo, NULL, git_buf_cstr(&path_workdir), + in_data.ptr = (char *)result.ptr; + in_data.size = result.len; + + if ((error = git_filter_list_load(&fl, data->repo, NULL, git_buf_cstr(&path_workdir), GIT_FILTER_TO_WORKTREE, GIT_FILTER_OPT_DEFAULT)) < 0 || (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0) goto done; - } else if ((error = git_buf_put(&out_data, result.ptr, result.len)) < 0) - goto done; - + } else { + out_data.ptr = (char *)result.ptr; + out_data.size = result.len; + } if ((error = git_futils_mkpath2file(path_workdir.ptr, 0755)) < 0 || (error = git_filebuf_open(&output, git_buf_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 || @@ -1832,7 +1835,6 @@ done: git_filter_list_free(fl); git_buf_free(&out_data); - git_buf_free(&in_data); git_buf_free(&our_label); git_buf_free(&their_label); |