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>
This commit is contained in:
parent
d599e0484f
commit
c8c073c420
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user