Merge pull request #178 from lightning-speed/patch-2
Replaced Multiple strlen(buffer) call with one call
This commit is contained in:
commit
dc3de36c7e
@ -412,6 +412,7 @@ refresh:
|
||||
term_double_buffer_flush();
|
||||
|
||||
int c = getchar();
|
||||
size_t buffer_len = strlen(buffer);
|
||||
switch (c) {
|
||||
case GETCHAR_CURSOR_DOWN:
|
||||
cursor_offset = get_next_line(cursor_offset, buffer);
|
||||
@ -425,7 +426,7 @@ refresh:
|
||||
}
|
||||
break;
|
||||
case GETCHAR_CURSOR_RIGHT:
|
||||
if (cursor_offset < strlen(buffer)) {
|
||||
if (cursor_offset < buffer_len) {
|
||||
cursor_offset++;
|
||||
}
|
||||
break;
|
||||
@ -458,9 +459,9 @@ refresh:
|
||||
editor_no_term_reset ? editor_no_term_reset = false : reset_term();
|
||||
return NULL;
|
||||
default:
|
||||
if (strlen(buffer) < EDITOR_MAX_BUFFER_SIZE - 1) {
|
||||
if (buffer_len < EDITOR_MAX_BUFFER_SIZE - 1) {
|
||||
if (isprint(c) || c == '\n') {
|
||||
for (size_t i = strlen(buffer); ; i--) {
|
||||
for (size_t i = buffer_len; ; i--) {
|
||||
buffer[i+1] = buffer[i];
|
||||
if (i == cursor_offset)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user