[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 23e9e8a 1/2: set_text_properties_1 can assume START
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 23e9e8a 1/2: set_text_properties_1 can assume START <= END |
Date: |
Wed, 12 Dec 2018 12:55:51 -0500 (EST) |
branch: master
commit 23e9e8abaab6f0c90412fc5fae08e5995a26d84c
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
set_text_properties_1 can assume START <= END
* src/textprop.c (set_text_properties_1):
Do not swap START and END. All callers do that already,
and the test for swapping here is redundant.
---
src/textprop.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/textprop.c b/src/textprop.c
index 8e8baf4..add14eb 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1421,34 +1421,25 @@ set_text_properties (Lisp_Object start, Lisp_Object
end, Lisp_Object properties,
/* Replace properties of text from START to END with new list of
properties PROPERTIES. OBJECT is the buffer or string containing
the text. This does not obey any hooks.
- You should provide the interval that START is located in as I.
- START and END can be in any order. */
+ I is the interval that START is located in. */
void
-set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object
properties, Lisp_Object object, INTERVAL i)
+set_text_properties_1 (Lisp_Object start, Lisp_Object end,
+ Lisp_Object properties, Lisp_Object object, INTERVAL i)
{
- register INTERVAL prev_changed = NULL;
- register ptrdiff_t s, len;
- INTERVAL unchanged;
+ INTERVAL prev_changed = NULL;
+ ptrdiff_t s = XFIXNUM (start);
+ ptrdiff_t len = XFIXNUM (end) - s;
- if (XFIXNUM (start) < XFIXNUM (end))
- {
- s = XFIXNUM (start);
- len = XFIXNUM (end) - s;
- }
- else if (XFIXNUM (end) < XFIXNUM (start))
- {
- s = XFIXNUM (end);
- len = XFIXNUM (start) - s;
- }
- else
+ if (len == 0)
return;
+ eassert (0 < len);
eassert (i);
if (i->position != s)
{
- unchanged = i;
+ INTERVAL unchanged = i;
i = split_interval_right (unchanged, s - unchanged->position);
if (LENGTH (i) > len)