From 78cef8778985b15bcb16a9ed9604395b3ab6b9c3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 1 Feb 2012 18:51:20 +0200 Subject: [PATCH] Speed up insertion of subprocess output on MS-Windows. src/ralloc.c (resize_bloc, r_alloc_sbrk): Don't call memmove if its first 2 arguments are identical. This makes inserting large output from a subprocess an order of magnitude faster on MS-Windows, where all sbrk'ed memory is always contiguous. --- src/ChangeLog | 7 +++++++ src/ralloc.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 81b5295a0c9..6d647530ad2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-02-01 Eli Zaretskii + + * ralloc.c (resize_bloc, r_alloc_sbrk): Don't call memmove if its + first 2 arguments are identical. This makes inserting large + output from a subprocess an order of magnitude faster on + MS-Windows, where all sbrk'ed memory is always contiguous. + 2012-01-31 Glenn Morris * nsterm.m (syms_of_nsterm) : diff --git a/src/ralloc.c b/src/ralloc.c index 13587b9ffd4..896ad9f3155 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -636,7 +636,8 @@ resize_bloc (bloc_ptr bloc, SIZE size) } else { - memmove (b->new_data, b->data, b->size); + if (b->new_data != b->data) + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } @@ -647,7 +648,8 @@ resize_bloc (bloc_ptr bloc, SIZE size) } else { - memmove (bloc->new_data, bloc->data, old_size); + if (bloc->new_data != bloc->data) + memmove (bloc->new_data, bloc->data, old_size); memset ((char *) bloc->new_data + old_size, 0, size - old_size); *bloc->variable = bloc->data = bloc->new_data; } @@ -663,7 +665,8 @@ resize_bloc (bloc_ptr bloc, SIZE size) } else { - memmove (b->new_data, b->data, b->size); + if (b->new_data != b->data) + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } @@ -816,7 +819,8 @@ r_alloc_sbrk (long int size) header. */ for (b = last_bloc; b != NIL_BLOC; b = b->prev) { - memmove (b->new_data, b->data, b->size); + if (b->new_data != b->data) + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } @@ -862,7 +866,8 @@ r_alloc_sbrk (long int size) for (b = first_bloc; b != NIL_BLOC; b = b->next) { - memmove (b->new_data, b->data, b->size); + if (b->new_data != b->data) + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } -- 2.11.4.GIT