diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2024-02-13 09:54:51 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2024-02-13 11:20:33 -0800 |
commit | 10c6aea4434b1c9ccea30a1f87f301ab2c9bade6 (patch) | |
tree | 80269754299a8edcb4cd33ba878f00617ced390c /src/lisp.h | |
parent | 473dac880105cf6055a185eb3b9764243f27697c (diff) | |
download | emacs-10c6aea4434b1c9ccea30a1f87f301ab2c9bade6.tar.gz |
Remove SYMBOL_WITH_POS_{POS,SYM}
* src/fns.c (internal_equal): Turn comment into eassert
that !symbols_with_pos_enabled.
(sxhash_obj): Simplify case of symbol with pos (when enabled).
* src/lisp.h (XSYMBOL_WITH_POS_SYM, XSYMBOL_WITH_POS_POS)
(maybe_remove_pos_from_symbol): New inline functions.
(SYMBOL_WITH_POS_SYM, SYMBOL_WITH_POS_POS): Remove.
All uses replaced by the new functions. This avoids some
double-checking in the source code, simplifies the code overall,
and avoids the need for "Type checking is done in the following
macro" comments to explain unusual code.
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/lisp.h b/src/lisp.h index 796c7867b4c..e9b0bd522af 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1113,6 +1113,27 @@ XSYMBOL_WITH_POS (Lisp_Object a) return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Symbol_With_Pos); } +INLINE Lisp_Object +XSYMBOL_WITH_POS_SYM (Lisp_Object a) +{ + Lisp_Object sym = XSYMBOL_WITH_POS (a)->sym; + eassert (BARE_SYMBOL_P (sym)); + return sym; +} + +INLINE Lisp_Object +XSYMBOL_WITH_POS_POS (Lisp_Object a) +{ + return XSYMBOL_WITH_POS (a)->pos; +} + +INLINE Lisp_Object +maybe_remove_pos_from_symbol (Lisp_Object x) +{ + return (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (x) + ? XSYMBOL_WITH_POS_SYM (x) : x); +} + INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED XBARE_SYMBOL (Lisp_Object a) { @@ -1128,7 +1149,7 @@ XSYMBOL (Lisp_Object a) if (!BARE_SYMBOL_P (a)) { eassert (symbols_with_pos_enabled); - a = XSYMBOL_WITH_POS (a)->sym; + a = XSYMBOL_WITH_POS_SYM (a); } return XBARE_SYMBOL (a); } @@ -1322,9 +1343,9 @@ INLINE bool EQ (Lisp_Object x, Lisp_Object y) { return BASE_EQ ((symbols_with_pos_enabled && SYMBOL_WITH_POS_P (x) - ? XSYMBOL_WITH_POS (x)->sym : x), + ? XSYMBOL_WITH_POS_SYM (x) : x), (symbols_with_pos_enabled && SYMBOL_WITH_POS_P (y) - ? XSYMBOL_WITH_POS (y)->sym : y)); + ? XSYMBOL_WITH_POS_SYM (y) : y)); } INLINE intmax_t @@ -2809,22 +2830,6 @@ XOVERLAY (Lisp_Object a) return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Overlay); } -INLINE Lisp_Object -SYMBOL_WITH_POS_SYM (Lisp_Object a) -{ - if (!SYMBOL_WITH_POS_P (a)) - wrong_type_argument (Qsymbol_with_pos_p, a); - return XSYMBOL_WITH_POS (a)->sym; -} - -INLINE Lisp_Object -SYMBOL_WITH_POS_POS (Lisp_Object a) -{ - if (!SYMBOL_WITH_POS_P (a)) - wrong_type_argument (Qsymbol_with_pos_p, a); - return XSYMBOL_WITH_POS (a)->pos; -} - INLINE bool USER_PTRP (Lisp_Object x) { |