mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
convert: return early when not tracing
When Git adds a file requiring encoding conversion and tracing of encoding conversion is not requested via the GIT_TRACE_WORKING_TREE_ENCODING environment variable, the `trace_encoding()` function still allocates & prepares "human readable" copies of the file contents before and after conversion to show in the trace. This results in a high memory footprint and increased runtime without providing any user-visible benefit. This fix introduces an early exit from the `trace_encoding()` function when tracing is not requested, preventing unnecessary memory allocation and processing. Signed-off-by: D Harithamma <harithamma.d@ibm.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c2b3f2b3cd
commit
63ad8dbf16
1 changed files with 3 additions and 0 deletions
|
@ -322,6 +322,9 @@ static void trace_encoding(const char *context, const char *path,
|
|||
struct strbuf trace = STRBUF_INIT;
|
||||
int i;
|
||||
|
||||
if (!trace_want(&coe))
|
||||
return;
|
||||
|
||||
strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding);
|
||||
for (i = 0; i < len && buf; ++i) {
|
||||
strbuf_addf(
|
||||
|
|
Loading…
Reference in a new issue