diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2024-01-06 08:22:08 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2024-01-06 08:22:08 +0100 |
commit | 37889523278fe65733938fb11c3701898309961c (patch) | |
tree | c7a2743ff17f1ce34686f26d73c4a5b9b68082d1 /src/dispnew.c | |
parent | 2740a3cbfde65a899f2fcefceee9c4bc06eebc2d (diff) | |
download | emacs-37889523278fe65733938fb11c3701898309961c.tar.gz |
Add new `swap` macro and use it
A `swap` macro prevents programming errors and is more concise.
It is a natural addition to our existing `min` and `max` macros.
* src/lisp.h (swap): New macro.
* lwlib/xlwmenu.c (draw_shadow_rectangle, draw_shadow_rhombus):
* src/androidterm.c (android_get_surrounding_text):
* src/buffer.c (Fmake_overlay, modify_overlay, Fmove_overlay):
* src/dispnew.c (swap_glyphs_in_rows, reverse_rows):
* src/editfns.c (Finsert_buffer_substring)
(Fcompare_buffer_substrings):
* src/eval.c (run_hook_wrapped_funcall):
* src/fns.c (extract_data_from_object):
* src/regex-emacs.c (forall_firstchar_1):
* src/textconv.c (textconv_query, get_extracted_text)
(get_surrounding_text):
* src/textprop.c (validate_interval_range)
(verify_interval_modification):
* src/w32uniscribe.c (OTF_INT16_VAL):
* src/xfaces.c (load_face_colors):
* src/xterm.c (SWAPCARD32): Prefer using above macro to open-coding.
Diffstat (limited to 'src/dispnew.c')
-rw-r--r-- | src/dispnew.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index d0f259eef6c..78ec3537a35 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -649,14 +649,7 @@ reverse_rows (struct glyph_matrix *matrix, int start, int end) int i, j; for (i = start, j = end - 1; i < j; ++i, --j) - { - /* Non-ISO HP/UX compiler doesn't like auto struct - initialization. */ - struct glyph_row temp; - temp = matrix->rows[i]; - matrix->rows[i] = matrix->rows[j]; - matrix->rows[j] = temp; - } + swap (matrix->rows[i], matrix->rows[j]); } @@ -966,9 +959,7 @@ increment_row_positions (struct glyph_row *row, static void swap_glyphs_in_rows (struct glyph_row *a, struct glyph_row *b) { - int area; - - for (area = 0; area < LAST_AREA; ++area) + for (int area = 0; area < LAST_AREA; ++area) { /* Number of glyphs to swap. */ int max_used = max (a->used[area], b->used[area]); @@ -984,12 +975,7 @@ swap_glyphs_in_rows (struct glyph_row *a, struct glyph_row *b) while (glyph_a < glyph_a_end) { - /* Non-ISO HP/UX compiler doesn't like auto struct - initialization. */ - struct glyph temp; - temp = *glyph_a; - *glyph_a = *glyph_b; - *glyph_b = temp; + swap (*glyph_a, *glyph_b); ++glyph_a; ++glyph_b; } |