diff options
author | Alexey Mahotkin <squadette@gmail.com> | 2010-04-28 15:29:06 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-05-01 11:11:11 -0700 |
commit | c8c073c4201600b958f5d3bd9e8051b2060bd3f7 (patch) | |
tree | 481db97fdc89064be771c3816fcab8cce710a5ca /xdiff | |
parent | d599e0484f8ebac8cc50e9557a4c3d246826843d (diff) | |
download | git-c8c073c4201600b958f5d3bd9e8051b2060bd3f7.tar.gz |
xdiff/xmerge.c: use memset() instead of explicit for-loop
memset() is heavily optimized, and resulting assembler code
is about 150 lines less for that file.
Signed-off-by: Alexey Mahotkin <squadette@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff')
-rw-r--r-- | xdiff/xmerge.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 16dd9acd37..6d6fc1bc5e 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -152,7 +152,6 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, int marker1_size = (name1 ? strlen(name1) + 1 : 0); int marker2_size = (name2 ? strlen(name2) + 1 : 0); int marker3_size = (name3 ? strlen(name3) + 1 : 0); - int j; if (marker_size <= 0) marker_size = DEFAULT_CONFLICT_MARKER_SIZE; @@ -164,8 +163,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, if (!dest) { size += marker_size + 1 + marker1_size; } else { - for (j = 0; j < marker_size; j++) - dest[size++] = '<'; + memset(dest + size, '<', marker_size); + size += marker_size; if (marker1_size) { dest[size] = ' '; memcpy(dest + size + 1, name1, marker1_size - 1); @@ -183,8 +182,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, if (!dest) { size += marker_size + 1 + marker3_size; } else { - for (j = 0; j < marker_size; j++) - dest[size++] = '|'; + memset(dest + size, '|', marker_size); + size += marker_size; if (marker3_size) { dest[size] = ' '; memcpy(dest + size + 1, name3, marker3_size - 1); @@ -199,8 +198,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, if (!dest) { size += marker_size + 1; } else { - for (j = 0; j < marker_size; j++) - dest[size++] = '='; + memset(dest + size, '=', marker_size); + size += marker_size; dest[size++] = '\n'; } @@ -210,8 +209,8 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, if (!dest) { size += marker_size + 1 + marker2_size; } else { - for (j = 0; j < marker_size; j++) - dest[size++] = '>'; + memset(dest + size, '>', marker_size); + size += marker_size; if (marker2_size) { dest[size] = ' '; memcpy(dest + size + 1, name2, marker2_size - 1); |