Mercurial > hg > xemacs-beta
diff src/redisplay.c @ 4844:91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
dynarr.c: Add comment explaining Dynarr_largest() use.
dynarr.c: In Dynarr_insert_many(), don't call Dynarr_resize() unless we
actually need to resize, and note that an assert() that we are
inserting at or below the current end could be wrong if code
wants to access stuff between `len' and `largest'.
dynarr.c: Don't just Dynarr_resize() to the right size; instead use
Dynarr_reset() then Dynarr_add_many(), so that the 'len' and
'largest' and such get set properly.
dynarr.c, faces.c, gutter.c, lisp.h, lread.c, lrecord.h, redisplay-output.c, redisplay.c: Rename Dynarr member 'cur' to 'len' since it's the length of
the dynarr, not really a pointer to a "current insertion point".
Use type_checking_assert() instead of just assert() in some places.
Add additional assertions (Dynarr_verify*()) to check that we're
being given positions within range. Use them in Dynarr_at,
Dynarr_atp, etc. New Dynarr_atp_allow_end() for retrieving a
pointer to a position that might be the element past the last one.
New Dynarr_past_lastp() to retrieve a pointer to the position
past the last one, using Dynarr_atp_allow_end(). Change code
appropriately to use it.
Rename Dynarr_end() to Dynarr_lastp() (pointer to the last
element) for clarity, and change code appropriately to use it.
Change code appropriately to use Dynarr_begin().
Rewrite Dynarr_add_many(). New version can accept a NULL pointer
to mean "reserve space but don't put anything in it". Used by
stack_like_malloc().
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 13 Jan 2010 04:07:42 -0600 |
parents | 6540302eedf5 |
children | ea701c23ed84 |
line wrap: on
line diff
--- a/src/redisplay.c Wed Jan 13 03:01:43 2010 -0600 +++ b/src/redisplay.c Wed Jan 13 04:07:42 2010 -0600 @@ -1160,7 +1160,7 @@ if (Dynarr_length (data->db->runes) < Dynarr_largest (data->db->runes)) { - crb = Dynarr_atp (data->db->runes, Dynarr_length (data->db->runes)); + crb = Dynarr_past_lastp (data->db->runes); local = 0; } else @@ -2436,8 +2436,8 @@ line and there are more glyphs to display then do appropriate processing to not get a continuation glyph. */ - if (*prop != ADD_FAILED - && Dynarr_atp (*prop, 0)->type == PROP_GLYPH + if (*prop != ADD_FAILED + && Dynarr_begin (*prop)->type == PROP_GLYPH && data.ch == '\n') { /* If there are no more glyphs then do the normal @@ -2448,8 +2448,8 @@ this we would have to carry the index around which might be problematic since the fragment is recalculated for each line. */ - if (EQ (Dynarr_end (tmpglyphs)->glyph, - Dynarr_atp (*prop, 0)->data.p_glyph.glyph)) + if (EQ (Dynarr_lastp (tmpglyphs)->glyph, + Dynarr_begin (*prop)->data.p_glyph.glyph)) { Dynarr_free (*prop); *prop = 0; @@ -2914,7 +2914,7 @@ db->start_pos = dl->bounds.left_in; if (Dynarr_length (db->runes)) { - struct rune *rb = Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); + struct rune *rb = Dynarr_lastp (db->runes); db->end_pos = rb->xpos + rb->width; } @@ -3829,8 +3829,7 @@ if (Dynarr_length (db->runes)) { - struct rune *rb = - Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); + struct rune *rb = Dynarr_lastp (db->runes); c_pixpos = rb->xpos + rb->width; } else @@ -3867,14 +3866,14 @@ strdata = XSTRING_DATA (result_str); for (elt = 0, len = 0; elt < Dynarr_length (db->runes); elt++) - { - if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) - { - len += (set_itext_ichar - (strdata + len, Dynarr_atp (db->runes, - elt)->object.chr.ch)); - } - } + { + if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) + { + len += (set_itext_ichar + (strdata + len, Dynarr_atp (db->runes, + elt)->object.chr.ch)); + } + } init_string_ascii_begin (result_str); bump_string_modiff (result_str); @@ -5162,7 +5161,7 @@ db->start_pos = dl->bounds.left_in; if (Dynarr_length (db->runes)) { - struct rune *rb = Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); + struct rune *rb = Dynarr_lastp (db->runes); db->end_pos = rb->xpos + rb->width; } @@ -6115,7 +6114,7 @@ { if (!MINI_WINDOW_P (w) && scroll_on_clipped_lines) { - dl = Dynarr_atp (dla, Dynarr_length (dla) - 1); + dl = Dynarr_lastp (dla); if (point >= (dl->charpos + dl->offset) && point <= (dl->end_charpos + dl->offset)) @@ -7594,7 +7593,7 @@ if (gba) { glyph_block *gb = Dynarr_atp (gba, 0); - glyph_block *gb_last = Dynarr_atp (gba, Dynarr_length (gba)); + glyph_block *gb_last = Dynarr_past_lastp (gba); for (; gb < gb_last; gb++) { @@ -7611,20 +7610,20 @@ void mark_redisplay_structs (display_line_dynarr *dla) { - display_line *dl = Dynarr_atp (dla, 0); - display_line *dl_last = Dynarr_atp (dla, Dynarr_length (dla)); + display_line *dl = Dynarr_begin (dla); + display_line *dl_last = Dynarr_past_lastp (dla); for (; dl < dl_last; dl++) { display_block_dynarr *dba = dl->display_blocks; - display_block *db = Dynarr_atp (dba, 0); - display_block *db_last = Dynarr_atp (dba, Dynarr_length (dba)); + display_block *db = Dynarr_begin (dba); + display_block *db_last = Dynarr_past_lastp (dba); for (; db < db_last; db++) { rune_dynarr *ra = db->runes; - rune *r = Dynarr_atp (ra, 0); - rune *r_last = Dynarr_atp (ra, Dynarr_length (ra)); + rune *r = Dynarr_begin (ra); + rune *r_last = Dynarr_past_lastp (ra); for (; r < r_last; r++) { @@ -7743,7 +7742,7 @@ if (!Dynarr_length (cache)) return -1; else - return Dynarr_atp (cache, Dynarr_length (cache) - 1)->end; + return Dynarr_lastp (cache)->end; } /* Return the index of the line POINT is contained within in window @@ -8380,9 +8379,8 @@ return; } - start = Dynarr_atp (internal_cache, 0)->start; - end = - Dynarr_atp (internal_cache, Dynarr_length (internal_cache) - 1)->end; + start = Dynarr_begin (internal_cache)->start; + end = Dynarr_lastp (internal_cache)->end; /* We aren't allowed to generate additional information to fill in gaps, so if the DESIRED structs don't overlap the cache, reset the @@ -8544,11 +8542,11 @@ /* Readjust the high_bound to account for any changes made while correcting the low_bound. */ - high_bound = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end; + high_bound = Dynarr_lastp (cache)->end; if (to > high_bound) { - Charbpos startp = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end + 1; + Charbpos startp = Dynarr_lastp (cache)->end + 1; do { @@ -8560,7 +8558,7 @@ Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), Dynarr_length (internal_cache)); - high_bound = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end; + high_bound = Dynarr_lastp (cache)->end; startp = high_bound + 1; } while (to > high_bound); @@ -8650,7 +8648,7 @@ if (Dynarr_length (dla)) { - struct display_line *dl = Dynarr_atp (dla, Dynarr_length (dla) - 1); + struct display_line *dl = Dynarr_lastp (dla); *pix_y = dl->ypos + dl->descent - dl->clip; } else @@ -9067,13 +9065,9 @@ else { if (dl->modeline) - *modeline_closest = - Dynarr_atp (db->runes, - Dynarr_length (db->runes) - 1)->charpos; + *modeline_closest = Dynarr_lastp (db->runes)->charpos; else - *closest = - Dynarr_atp (db->runes, - Dynarr_length (db->runes) - 1)->charpos; + *closest = Dynarr_lastp (db->runes)->charpos; } if (dl->modeline)