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/textprop.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/textprop.c')
-rw-r--r-- | src/textprop.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/textprop.c b/src/textprop.c index 7d9aae0d2c5..ec9435219ea 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -142,12 +142,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, return NULL; if (XFIXNUM (*begin) > XFIXNUM (*end)) - { - Lisp_Object n; - n = *begin; - *begin = *end; - *end = n; - } + swap (*begin, *end); if (BUFFERP (object)) { @@ -2201,11 +2196,7 @@ verify_interval_modification (struct buffer *buf, return; if (start > end) - { - ptrdiff_t temp = start; - start = end; - end = temp; - } + swap (start, end); /* For an insert operation, check the two chars around the position. */ if (start == end) |