[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 888bf98 05/10: Avoid allocating a Lisp_Save_Value i
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 888bf98 05/10: Avoid allocating a Lisp_Save_Value in ftfont.c |
Date: |
Thu, 14 Jun 2018 20:15:24 -0400 (EDT) |
branch: master
commit 888bf9877d466dbb65aec821bede9ac49e12798f
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Avoid allocating a Lisp_Save_Value in ftfont.c
* src/ftfont.c (struct ftfont_cache_data): New member face_refcount.
(ftfont_lookup_cache): Clear it when initializing.
Use make_mint_ptr, since this typically avoids the need to
allocate a Lisp_Save_Value as refcount is now stored elsewhere.
(ftfont_open2, ftfont_close): Manipulate the reference
count in the struct, not in the save object.
---
src/ftfont.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/ftfont.c b/src/ftfont.c
index a534670..d50fa39 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -345,6 +345,7 @@ struct ftfont_cache_data
{
FT_Face ft_face;
FcCharSet *fc_charset;
+ intptr_t face_refcount;
};
static Lisp_Object
@@ -371,17 +372,15 @@ ftfont_lookup_cache (Lisp_Object key, enum
ftfont_cache_for cache_for)
{
if (NILP (ft_face_cache))
ft_face_cache = CALLN (Fmake_hash_table, QCtest, Qequal);
- cache_data = xmalloc (sizeof *cache_data);
- cache_data->ft_face = NULL;
- cache_data->fc_charset = NULL;
- val = make_save_ptr_int (cache_data, 0);
+ cache_data = xzalloc (sizeof *cache_data);
+ val = make_mint_ptr (cache_data);
cache = Fcons (Qnil, val);
Fputhash (key, cache, ft_face_cache);
}
else
{
val = XCDR (cache);
- cache_data = XSAVE_POINTER (val, 0);
+ cache_data = xmint_pointer (val);
}
if (cache_for == FTFONT_CACHE_FOR_ENTITY)
@@ -447,7 +446,7 @@ ftfont_get_fc_charset (Lisp_Object entity)
cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_CHARSET);
val = XCDR (cache);
- cache_data = XSAVE_POINTER (val, 0);
+ cache_data = xmint_pointer (val);
return cache_data->fc_charset;
}
@@ -1118,9 +1117,9 @@ ftfont_open2 (struct frame *f,
filename = XCAR (val);
idx = XCDR (val);
val = XCDR (cache);
- cache_data = XSAVE_POINTER (XCDR (cache), 0);
+ cache_data = xmint_pointer (XCDR (cache));
ft_face = cache_data->ft_face;
- if (XSAVE_INTEGER (val, 1) > 0)
+ if (cache_data->face_refcount > 0)
{
/* FT_Face in this cache is already used by the different size. */
if (FT_New_Size (ft_face, &ft_size) != 0)
@@ -1136,14 +1135,14 @@ ftfont_open2 (struct frame *f,
size = pixel_size;
if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
{
- if (XSAVE_INTEGER (val, 1) == 0)
+ if (cache_data->face_refcount == 0)
{
FT_Done_Face (ft_face);
cache_data->ft_face = NULL;
}
return Qnil;
}
- set_save_integer (val, 1, XSAVE_INTEGER (val, 1) + 1);
+ cache_data->face_refcount++;
ASET (font_object, FONT_FILE_INDEX, filename);
font = XFONT_OBJECT (font_object);
@@ -1255,11 +1254,10 @@ ftfont_close (struct font *font)
cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE);
eassert (CONSP (cache));
val = XCDR (cache);
- set_save_integer (val, 1, XSAVE_INTEGER (val, 1) - 1);
- if (XSAVE_INTEGER (val, 1) == 0)
+ struct ftfont_cache_data *cache_data = xmint_pointer (val);
+ cache_data->face_refcount--;
+ if (cache_data->face_refcount == 0)
{
- struct ftfont_cache_data *cache_data = XSAVE_POINTER (val, 0);
-
FT_Done_Face (cache_data->ft_face);
#ifdef HAVE_LIBOTF
if (ftfont_info->otf)
- [Emacs-diffs] master updated (51adab5 -> 4139c98), Paul Eggert, 2018/06/14
- [Emacs-diffs] master 12fd59b 03/10: Avoid Lisp_Misc allocation if C stack suffices, Paul Eggert, 2018/06/14
- [Emacs-diffs] master ef66660 02/10: Simplify init_module_assertions, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 3f0a8a2 04/10: Use record_unwind_protect_ptr to avoid allocation, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 30d393f 01/10: New mint_ptr representation for C pointers, Paul Eggert, 2018/06/14
- [Emacs-diffs] master d98670e 08/10: Avoid allocating Lisp_Save_Value for arrays, Paul Eggert, 2018/06/14
- [Emacs-diffs] master f8ad6b3 09/10: New type Lisp_Misc_Ptr, Paul Eggert, 2018/06/14
- [Emacs-diffs] master aca938d 07/10: Avoid allocating Lisp_Save_Value for excursions, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 888bf98 05/10: Avoid allocating a Lisp_Save_Value in ftfont.c,
Paul Eggert <=
- [Emacs-diffs] master 6c04c84 06/10: Just use cons in macfont_descriptor_entity, Paul Eggert, 2018/06/14
- [Emacs-diffs] master 4139c98 10/10: Remove Lisp_Misc_Save_Value, Paul Eggert, 2018/06/14