emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/mac.c


From: YAMAMOTO Mitsuharu
Subject: [Emacs-diffs] Changes to emacs/src/mac.c
Date: Tue, 15 Nov 2005 02:56:14 -0500

Index: emacs/src/mac.c
diff -c emacs/src/mac.c:1.46 emacs/src/mac.c:1.47
*** emacs/src/mac.c:1.46        Wed Nov  9 08:07:59 2005
--- emacs/src/mac.c     Tue Nov 15 07:56:14 2005
***************
*** 854,862 ****
     implemented as a hash table that maps a pair (SRC-NODE-ID .
     EDGE-LABEL) to DEST-NODE-ID.  It also holds a maximum node id used
     in the table as a value for HASHKEY_MAX_NID.  A value associated to
!    a node is recorded as a value for the node id.  */
  
  #define HASHKEY_MAX_NID (make_number (0))
  
  static XrmDatabase
  xrm_create_database ()
--- 854,867 ----
     implemented as a hash table that maps a pair (SRC-NODE-ID .
     EDGE-LABEL) to DEST-NODE-ID.  It also holds a maximum node id used
     in the table as a value for HASHKEY_MAX_NID.  A value associated to
!    a node is recorded as a value for the node id.
! 
!    A database also has a cache for past queries as a value for
!    HASHKEY_QUERY_CACHE.  It is another hash table that maps
!    "NAME-STRING\0CLASS-STRING" to the result of the query.  */
  
  #define HASHKEY_MAX_NID (make_number (0))
+ #define HASHKEY_QUERY_CACHE (make_number (-1))
  
  static XrmDatabase
  xrm_create_database ()
***************
*** 868,873 ****
--- 873,879 ----
                              make_float (DEFAULT_REHASH_THRESHOLD),
                              Qnil, Qnil, Qnil);
    Fputhash (HASHKEY_MAX_NID, make_number (0), database);
+   Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
  
    return database;
  }
***************
*** 901,906 ****
--- 907,913 ----
    Fputhash (node_id, value, database);
  
    Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);
+   Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
  }
  
  /* Merge multiple resource entries specified by DATA into a resource
***************
*** 989,996 ****
       XrmDatabase database;
       char *name, *class;
  {
!   Lisp_Object quark_name, quark_class, tmp;
!   int nn, nc;
  
    quark_name = parse_resource_name (&name);
    if (*name != '\0')
--- 996,1025 ----
       XrmDatabase database;
       char *name, *class;
  {
!   Lisp_Object key, query_cache, quark_name, quark_class, tmp;
!   int i, nn, nc;
!   struct Lisp_Hash_Table *h;
!   unsigned hash_code;
! 
!   nn = strlen (name);
!   nc = strlen (class);
!   key = make_uninit_string (nn + nc + 1);
!   strcpy (SDATA (key), name);
!   strncpy (SDATA (key) + nn + 1, class, nc);
! 
!   query_cache = Fgethash (HASHKEY_QUERY_CACHE, database, Qnil);
!   if (NILP (query_cache))
!     {
!       query_cache = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
!                                    make_float (DEFAULT_REHASH_SIZE),
!                                    make_float (DEFAULT_REHASH_THRESHOLD),
!                                    Qnil, Qnil, Qnil);
!       Fputhash (HASHKEY_QUERY_CACHE, query_cache, database);
!     }
!   h = XHASH_TABLE (query_cache);
!   i = hash_lookup (h, key, &hash_code);
!   if (i >= 0)
!     return HASH_VALUE (h, i);
  
    quark_name = parse_resource_name (&name);
    if (*name != '\0')
***************
*** 1009,1015 ****
    if (nn != nc)
      return Qnil;
    else
!     return xrm_q_get_resource (database, quark_name, quark_class);
  }
  
  #if TARGET_API_MAC_CARBON
--- 1038,1048 ----
    if (nn != nc)
      return Qnil;
    else
!     {
!       tmp = xrm_q_get_resource (database, quark_name, quark_class);
!       hash_put (h, key, tmp, hash_code);
!       return tmp;
!     }
  }
  
  #if TARGET_API_MAC_CARBON




reply via email to

[Prev in Thread] Current Thread [Next in Thread]