[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs buffer.c qe.h qe.c shell.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs buffer.c qe.h qe.c shell.c |
Date: |
Tue, 13 Dec 2016 17:20:51 +0000 (UTC) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/12/13 17:20:51
Modified files:
. : buffer.c qe.h qe.c shell.c
Log message:
display: optimize low level buffer content read functions
- remove style handling from eb_nextc()
- add eb_nextc_style()
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.102&r2=1.103
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.223&r2=1.224
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.230&r2=1.231
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.112&r2=1.113
Patches:
Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- buffer.c 7 Jun 2016 08:56:40 -0000 1.102
+++ buffer.c 13 Dec 2016 17:20:51 -0000 1.103
@@ -95,7 +95,7 @@
int len, remain;
const Page *p;
- /* We carefully clip the request, avoiding and integer overflow */
+ /* We carefully clip the request, avoiding integer overflow */
if (offset < 0 || size <= 0 || offset >= b->total_size)
return 0;
@@ -1415,22 +1415,7 @@
u8 buf[MAX_CHAR_BYTES];
int ch;
- if (b->b_styles) {
- if (b->style_shift == 2) {
- uint32_t style = 0;
- eb_read(b->b_styles, (offset >> b->char_shift) << 2, &style, 4);
- b->cur_style = style;
- } else
- if (b->style_shift == 1) {
- uint16_t style = 0;
- eb_read(b->b_styles, (offset >> b->char_shift) << 1, &style, 2);
- b->cur_style = style;
- } else {
- uint8_t style = 0;
- eb_read(b->b_styles, (offset >> b->char_shift), &style, 1);
- b->cur_style = style;
- }
- }
+ /* XXX: should inline this */
ch = eb_read_one_byte(b, offset);
if (ch < 0) {
/* to simplify calling code, return '\n' at buffer boundaries */
@@ -1473,6 +1458,27 @@
return ch;
}
+int eb_nextc_style(EditBuffer *b, int offset, int *next_ptr)
+{
+ if (b->b_styles) {
+ if (b->style_shift == 2) {
+ uint32_t style = 0;
+ eb_read(b->b_styles, (offset >> b->char_shift) << 2, &style, 4);
+ b->cur_style = style;
+ } else
+ if (b->style_shift == 1) {
+ uint16_t style = 0;
+ eb_read(b->b_styles, (offset >> b->char_shift) << 1, &style, 2);
+ b->cur_style = style;
+ } else {
+ uint8_t style = 0;
+ eb_read(b->b_styles, (offset >> b->char_shift), &style, 1);
+ b->cur_style = style;
+ }
+ }
+ return eb_nextc(b, offset, next_ptr);
+}
+
/* compute offset after moving 'n' chars from 'offset'.
* 'n' can be negative
*/
@@ -2294,6 +2300,7 @@
stop = clamp(stop, 0, b->total_size);
start = clamp(start, 0, stop);
+ /* assuming start and stop fall on character boundaries */
if (b->charset == &charset_utf8 && b->eol_type == EOL_UNIX) {
return stop - start;
} else {
@@ -2342,7 +2349,7 @@
size = 0;
for (offset = src_offset; offset < offset_max;) {
char buf[MAX_CHAR_BYTES];
- int c = eb_nextc(src, offset, &offset);
+ int c = eb_nextc_style(src, offset, &offset);
int len = eb_encode_uchar(b, buf, c);
b->cur_style = src->cur_style;
size += eb_insert(b, offset1 + size, buf, len);
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -b -r1.223 -r1.224
--- qe.h 26 Nov 2016 11:30:29 -0000 1.223
+++ qe.h 13 Dec 2016 17:20:51 -0000 1.224
@@ -987,6 +987,8 @@
qe__attr_nonnull((3))
int eb_nextc(EditBuffer *b, int offset, int *next_ptr);
qe__attr_nonnull((3))
+int eb_nextc_style(EditBuffer *b, int offset, int *next_ptr);
+qe__attr_nonnull((3))
int eb_prevc(EditBuffer *b, int offset, int *prev_ptr);
int eb_skip_chars(EditBuffer *b, int offset, int n);
int eb_delete_chars(EditBuffer *b, int offset, int n);
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -b -r1.230 -r1.231
--- qe.c 26 Nov 2016 11:30:29 -0000 1.230
+++ qe.c 13 Dec 2016 17:20:51 -0000 1.231
@@ -2284,7 +2284,7 @@
/* slow, but simple iterative method */
for (offset = 0; offset < b->total_size;) {
- c = eb_nextc(b, offset, &offset);
+ c = eb_nextc_style(b, offset, &offset);
b1->cur_style = b->cur_style;
len = eb_encode_uchar(b1, buf, c);
eb_insert(b1, b1->total_size, buf, len);
@@ -3631,7 +3631,7 @@
buf_end = buf + buf_size - 1;
b->cur_style = 0;
for (;;) {
- c = eb_nextc(b, offset, &offset);
+ c = eb_nextc_style(b, offset, &offset);
if (c == '\n')
break;
if (buf_ptr < buf_end) {
@@ -3757,7 +3757,7 @@
buf_end = buf + buf_size - 1;
b->cur_style = 0;
for (;;) {
- c = eb_nextc(b, offset, &offset);
+ c = eb_nextc_style(b, offset, &offset);
if (c == '\n')
break;
if (buf_ptr < buf_end) {
Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -b -r1.112 -r1.113
--- shell.c 26 Nov 2016 11:30:29 -0000 1.112
+++ shell.c 13 Dec 2016 17:20:51 -0000 1.113
@@ -503,7 +503,7 @@
offset = s->cur_offset;
buf[0] = c;
- c1 = eb_nextc(s->b, offset, &offset1);
+ c1 = eb_nextc_style(s->b, offset, &offset1);
s->b->cur_style = QE_STYLE_TTY | s->color | s->attr;
if (c1 == '\n') {
/* insert */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs buffer.c qe.h qe.c shell.c,
Charlie Gordon <=