summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-11-15 09:01:19 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-11-15 09:01:19 +0100
commitf435e8d3fa0cf50fa7db643c8d4e698292581467 (patch)
tree2938d191406c7fb4896b742071e63d45fbb72d89 /src/core/wee-command.c
parentd1a89e9db0b0ed0776063648844f808b4f326a43 (diff)
downloadweechat-f435e8d3fa0cf50fa7db643c8d4e698292581467.zip
core: optimize loop when closing several buffers with command /buffer close n1-n2
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 2af76305f..815a647f7 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -801,26 +801,25 @@ COMMAND_CALLBACK(buffer)
{
error_main_buffer = 0;
num_buffers = 0;
- for (i = number2; i >= number1; i--)
+ ptr_buffer = last_gui_buffer;
+ while (ptr_buffer)
{
- ptr_buffer = last_gui_buffer;
- while (ptr_buffer)
+ ptr_prev_buffer = ptr_buffer->prev_buffer;
+ if (ptr_buffer->number < number1)
+ break;
+ if (ptr_buffer->number <= number2)
{
- ptr_prev_buffer = ptr_buffer->prev_buffer;
- if (ptr_buffer->number == i)
+ num_buffers++;
+ if (ptr_buffer == weechat_buffer)
{
- num_buffers++;
- if (ptr_buffer == weechat_buffer)
- {
- error_main_buffer = 1;
- }
- else
- {
- gui_buffer_close (ptr_buffer);
- }
+ error_main_buffer = 1;
+ }
+ else
+ {
+ gui_buffer_close (ptr_buffer);
}
- ptr_buffer = ptr_prev_buffer;
}
+ ptr_buffer = ptr_prev_buffer;
}
/*
* display error for main buffer if it was the only