Skip to content

Commit 63ad8db

Browse files
HarithaIBMgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2b3f2b commit 63ad8db

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

convert.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ static void trace_encoding(const char *context, const char *path,
322322
struct strbuf trace = STRBUF_INIT;
323323
int i;
324324

325+
if (!trace_want(&coe))
326+
return;
327+
325328
strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding);
326329
for (i = 0; i < len && buf; ++i) {
327330
strbuf_addf(

0 commit comments

Comments
 (0)