diff options
| author | Paul Eggert | 2020-08-15 10:48:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-08-15 11:19:51 -0700 |
| commit | f1b06fd5fc66377f85b420d3d40c666da9dca2a5 (patch) | |
| tree | 588b05ababc36aaec1d28f6543aa35b180cba79c /src/fontset.c | |
| parent | d0145537fa511a44e2a4af01da3947e92f0b8331 (diff) | |
| download | emacs-f1b06fd5fc66377f85b420d3d40c666da9dca2a5.tar.gz emacs-f1b06fd5fc66377f85b420d3d40c666da9dca2a5.zip | |
Prefer Fvector to make_uninit_vector
Fvector is less error-prone than make_uninit_vector, as it
avoids the possibility of a GC crash due to an uninitialized
vector. So prefer Fvector to make_uninit_vector when this is
easy (and when there's no significant performance difference).
Inspired by a suggestion by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2020-08/msg00313.html
* src/ccl.c (Fregister_ccl_program):
* src/ccl.c (Fregister_ccl_program):
* src/charset.c (Fdefine_charset_internal):
* src/font.c (Fquery_font, Ffont_info, syms_of_font):
* src/fontset.c (font_def_new, Fset_fontset_font):
* src/ftfont.c (ftfont_shape_by_flt):
* src/hbfont.c (hbfont_shape):
* src/macfont.m (macfont_shape):
* src/search.c (Fnewline_cache_check):
* src/xfaces.c (Fx_family_fonts):
* src/xfns.c (Fx_window_property_attributes):
Prefer Fvector to make_uninit_vector when either is easy.
* src/fontset.c (font_def_new): Now a function with one less
arg instead of a do-while macro, and renamed from FONT_DEF_NEW.
All uses changed.
Diffstat (limited to 'src/fontset.c')
| -rw-r--r-- | src/fontset.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/fontset.c b/src/fontset.c index c2bb8b21f26..8c86075c07e 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -252,14 +252,13 @@ set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback) | |||
| 252 | 252 | ||
| 253 | #define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) | 253 | #define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) |
| 254 | 254 | ||
| 255 | /* Macros for FONT-DEF and RFONT-DEF of fontset. */ | 255 | /* Definitions for FONT-DEF and RFONT-DEF of fontset. */ |
| 256 | #define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \ | 256 | static Lisp_Object |
| 257 | do { \ | 257 | font_def_new (Lisp_Object font_spec, Lisp_Object encoding, |
| 258 | (font_def) = make_uninit_vector (3); \ | 258 | Lisp_Object repertory) |
| 259 | ASET ((font_def), 0, font_spec); \ | 259 | { |
| 260 | ASET ((font_def), 1, encoding); \ | 260 | return CALLN (Fvector, font_spec, encoding, repertory); |
| 261 | ASET ((font_def), 2, repertory); \ | 261 | } |
| 262 | } while (0) | ||
| 263 | 262 | ||
| 264 | #define FONT_DEF_SPEC(font_def) AREF (font_def, 0) | 263 | #define FONT_DEF_SPEC(font_def) AREF (font_def, 0) |
| 265 | #define FONT_DEF_ENCODING(font_def) AREF (font_def, 1) | 264 | #define FONT_DEF_ENCODING(font_def) AREF (font_def, 1) |
| @@ -1547,7 +1546,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1547 | repertory = CHARSET_SYMBOL_ID (repertory); | 1546 | repertory = CHARSET_SYMBOL_ID (repertory); |
| 1548 | } | 1547 | } |
| 1549 | } | 1548 | } |
| 1550 | FONT_DEF_NEW (font_def, font_spec, encoding, repertory); | 1549 | font_def = font_def_new (font_spec, encoding, repertory); |
| 1551 | } | 1550 | } |
| 1552 | else | 1551 | else |
| 1553 | font_def = Qnil; | 1552 | font_def = Qnil; |
| @@ -1619,14 +1618,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1619 | 1618 | ||
| 1620 | if (charset) | 1619 | if (charset) |
| 1621 | { | 1620 | { |
| 1622 | Lisp_Object arg; | 1621 | Lisp_Object arg = CALLN (Fvector, fontset, font_def, add, |
| 1623 | 1622 | ascii_changed ? Qt : Qnil, range_list); | |
| 1624 | arg = make_uninit_vector (5); | ||
| 1625 | ASET (arg, 0, fontset); | ||
| 1626 | ASET (arg, 1, font_def); | ||
| 1627 | ASET (arg, 2, add); | ||
| 1628 | ASET (arg, 3, ascii_changed ? Qt : Qnil); | ||
| 1629 | ASET (arg, 4, range_list); | ||
| 1630 | 1623 | ||
| 1631 | map_charset_chars (set_fontset_font, Qnil, arg, charset, | 1624 | map_charset_chars (set_fontset_font, Qnil, arg, charset, |
| 1632 | CHARSET_MIN_CODE (charset), | 1625 | CHARSET_MIN_CODE (charset), |