-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: af6eb8730dd7f11089ef8ba0b41f08cc39d098d7: path_to: revision_to:
commit af6eb8730dd7f11089ef8ba0b41f08cc39d098d7 Author: Marc Lehmann <schmorp@schmorp.de> Date: Mon Jul 21 16:51:31 2008 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- a/Changes +++ b/Changes @@ -21,6 +21,9 @@ DUMB: support tex fonts TODO: /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ + - ignore byte-order marks and do not treat them like combining characters. + - do some ยต-optimisations to the character fast path. + 9.05 Sun Jun 15 20:09:20 CEST 2008 - new option --cd/chdir to set the starting working directory. - tabbed extension now starts in the "correct" working directory. diff --git a/src/command.C b/src/command.C
--- a/src/command.C +++ b/src/command.C @@ -2181,7 +2181,7 @@ rxvt_term::cmd_parse () for (;;) { - if (ch == NOCHAR) + if (expect_false (ch == NOCHAR)) { seq_begin = cmdbuf_ptr; ch = next_char (); @@ -2190,9 +2190,9 @@ rxvt_term::cmd_parse () break; } - if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) + if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) { - if (!seen_input) + if (expect_false (!seen_input)) { seen_input = 1; // many badly-written programs (e.g. jed) contain a race condition: @@ -2215,12 +2215,12 @@ rxvt_term::cmd_parse () for (;;) { - if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) + if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) break; *str++ = ch; - if (ch == C0_LF || str >= eol) + if (expect_false (ch == C0_LF || str >= eol)) { if (ch == C0_LF) nlines++; @@ -2312,7 +2312,7 @@ rxvt_term::next_char () NOTHROW while (cmdbuf_ptr < cmdbuf_endp) { // assume 7-bit to be ascii ALWAYS - if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) + if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) return *cmdbuf_ptr++; wchar_t wc; diff --git a/src/rxvtutil.h b/src/rxvtutil.h
--- a/src/rxvtutil.h +++ b/src/rxvtutil.h @@ -15,10 +15,18 @@ using namespace std; #if __GNUC__ >= 4 # define rxvt_attribute(x) __attribute__(x) +# define expect(expr,value) __builtin_expect ((expr),(value)) #else # define rxvt_attribute(x) +# define expect(expr,value) (expr) #endif +// put into ifs if you are very sure that the expression +// is mostly true or mosty false. note that these return +// booleans, not the expression. +#define expect_false(expr) expect ((expr) != 0, 0) +#define expect_true(expr) expect ((expr) != 0, 1) + #define NORETURN rxvt_attribute ((noreturn)) #define UNUSED rxvt_attribute ((unused)) #define CONST rxvt_attribute ((const)) diff --git a/src/screen.C b/src/screen.C
--- a/src/screen.C +++ b/src/screen.C @@ -773,7 +773,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW { c = (unicode_t)*str++; // convert to rxvt-unicodes representation - if (c < 0x20) + if (expect_false (c < 0x20)) if (c == C0_LF) { max_it (line->l, screen.cur.col); @@ -802,9 +802,11 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW continue; } - if (checksel /* see if we're writing within selection */ - && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) - && ROWCOL_IS_BEFORE (screen.cur, selection.end)) + if (expect_false ( + checksel /* see if we're writing within selection */ + && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) + && ROWCOL_IS_BEFORE (screen.cur, selection.end) + )) { checksel = 0; /* @@ -815,7 +817,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW CLEAR_SELECTION (); } - if (screen.flags & Screen_WrapNext) + if (expect_false (screen.flags & Screen_WrapNext)) { scr_do_wrap (); @@ -827,7 +829,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW } // some utf-8 decoders "decode" surrogate characters: let's fix this. - if (IN_RANGE_INC (c, 0xd800, 0xdfff)) + if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) c = 0xfffd; // rely on wcwidth to tell us the character width, do wcwidth before @@ -836,7 +838,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW // locale. int width = WCWIDTH (c); - if (charsets [screen.charset] == '0') // DEC SPECIAL + if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL { // vt100 special graphics and line drawing // 5f-7e standard vt100 @@ -859,7 +861,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW } } - if (screen.flags & Screen_Insert) + if (expect_false (screen.flags & Screen_Insert)) scr_insdel_chars (width, INSERT); if (width != 0) @@ -875,9 +877,11 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW #endif // nuke the character at this position, if required - if (line->t[screen.cur.col] == NOCHAR - || (screen.cur.col < ncol - 1 - && line->t[screen.cur.col + 1] == NOCHAR)) + if (expect_false ( + line->t[screen.cur.col] == NOCHAR + || (screen.cur.col < ncol - 1 + && line->t[screen.cur.col + 1] == NOCHAR) + )) { int col = screen.cur.col; @@ -898,7 +902,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); // if the character doesn't fit into the remaining columns... - if (screen.cur.col > ncol - width && ncol >= width) + if (expect_false (screen.cur.col > ncol - width && ncol >= width)) { // ...output spaces c = ' '; @@ -913,7 +917,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW line->t[screen.cur.col] = c; line->r[screen.cur.col] = rend; - if (screen.cur.col < ncol - 1) + if (expect_true (screen.cur.col < ncol - 1)) screen.cur.col++; else { @@ -925,10 +929,10 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW c = NOCHAR; } - while (--width > 0); + while (expect_false (--width > 0)); // pad with spaces when overwriting wide character with smaller one - if (!width) + if (expect_false (!width)) { line->touch (); @@ -939,47 +943,50 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW } } } +#if ENABLE_COMBINING else // width == 0 { -#if ENABLE_COMBINING - // handle combining characters - // we just tag the accent on the previous on-screen character. - // this is arguably not correct, but also arguably not wrong. - // we don't handle double-width characters nicely yet. - line_t *linep; - text_t *tp; - rend_t *rp; - - if (screen.cur.col > 0) + if (c != 0xfeff) // ignore BOM { - linep = line; - tp = line->t + screen.cur.col - 1; - rp = line->r + screen.cur.col - 1; - } - else if (screen.cur.row > 0 - && ROW(screen.cur.row - 1).is_longer ()) - { - linep = &ROW(screen.cur.row - 1); - tp = line->t + ncol - 1; - rp = line->r + ncol - 1; - } - else - continue; + // handle combining characters + // we just tag the accent on the previous on-screen character. + // this is arguably not correct, but also arguably not wrong. + // we don't handle double-width characters nicely yet. + line_t *linep; + text_t *tp; + rend_t *rp; + + if (screen.cur.col > 0) + { + linep = line; + tp = line->t + screen.cur.col - 1; + rp = line->r + screen.cur.col - 1; + } + else if (screen.cur.row > 0 + && ROW(screen.cur.row - 1).is_longer ()) + { + linep = &ROW(screen.cur.row - 1); + tp = line->t + ncol - 1; + rp = line->r + ncol - 1; + } + else + continue; - linep->touch (); + linep->touch (); - while (*tp == NOCHAR && tp > linep->t) - tp--, rp--; + while (*tp == NOCHAR && tp > linep->t) + tp--, rp--; - // first try to find a precomposed character - unicode_t n = rxvt_compose (*tp, c); - if (n == NOCHAR) - n = rxvt_composite.compose (*tp, c); + // first try to find a precomposed character + unicode_t n = rxvt_compose (*tp, c); + if (n == NOCHAR) + n = rxvt_composite.compose (*tp, c); - *tp = n; - *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); -#endif + *tp = n; + *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); + } } +#endif } max_it (line->l, screen.cur.col);
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 10:55:11 2024