/[emacs]/emacs/src/mac.c
ViewVC logotype

Diff of /emacs/src/mac.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by mituharu, Wed Nov 9 08:07:59 2005 UTC revision 1.47 by mituharu, Tue Nov 15 07:56:14 2005 UTC
# Line 854  parse_resource_line (p) Line 854  parse_resource_line (p)
854     implemented as a hash table that maps a pair (SRC-NODE-ID .     implemented as a hash table that maps a pair (SRC-NODE-ID .
855     EDGE-LABEL) to DEST-NODE-ID.  It also holds a maximum node id used     EDGE-LABEL) to DEST-NODE-ID.  It also holds a maximum node id used
856     in the table as a value for HASHKEY_MAX_NID.  A value associated to     in the table as a value for HASHKEY_MAX_NID.  A value associated to
857     a node is recorded as a value for the node id.  */     a node is recorded as a value for the node id.
858    
859       A database also has a cache for past queries as a value for
860       HASHKEY_QUERY_CACHE.  It is another hash table that maps
861       "NAME-STRING\0CLASS-STRING" to the result of the query.  */
862    
863  #define HASHKEY_MAX_NID (make_number (0))  #define HASHKEY_MAX_NID (make_number (0))
864    #define HASHKEY_QUERY_CACHE (make_number (-1))
865    
866  static XrmDatabase  static XrmDatabase
867  xrm_create_database ()  xrm_create_database ()
# Line 868  xrm_create_database () Line 873  xrm_create_database ()
873                                make_float (DEFAULT_REHASH_THRESHOLD),                                make_float (DEFAULT_REHASH_THRESHOLD),
874                                Qnil, Qnil, Qnil);                                Qnil, Qnil, Qnil);
875    Fputhash (HASHKEY_MAX_NID, make_number (0), database);    Fputhash (HASHKEY_MAX_NID, make_number (0), database);
876      Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
877    
878    return database;    return database;
879  }  }
# Line 901  xrm_q_put_resource (database, quarks, va Line 907  xrm_q_put_resource (database, quarks, va
907    Fputhash (node_id, value, database);    Fputhash (node_id, value, database);
908    
909    Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);    Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);
910      Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
911  }  }
912    
913  /* Merge multiple resource entries specified by DATA into a resource  /* Merge multiple resource entries specified by DATA into a resource
# Line 989  xrm_get_resource (database, name, class) Line 996  xrm_get_resource (database, name, class)
996       XrmDatabase database;       XrmDatabase database;
997       char *name, *class;       char *name, *class;
998  {  {
999    Lisp_Object quark_name, quark_class, tmp;    Lisp_Object key, query_cache, quark_name, quark_class, tmp;
1000    int nn, nc;    int i, nn, nc;
1001      struct Lisp_Hash_Table *h;
1002      unsigned hash_code;
1003    
1004      nn = strlen (name);
1005      nc = strlen (class);
1006      key = make_uninit_string (nn + nc + 1);
1007      strcpy (SDATA (key), name);
1008      strncpy (SDATA (key) + nn + 1, class, nc);
1009    
1010      query_cache = Fgethash (HASHKEY_QUERY_CACHE, database, Qnil);
1011      if (NILP (query_cache))
1012        {
1013          query_cache = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
1014                                         make_float (DEFAULT_REHASH_SIZE),
1015                                         make_float (DEFAULT_REHASH_THRESHOLD),
1016                                         Qnil, Qnil, Qnil);
1017          Fputhash (HASHKEY_QUERY_CACHE, query_cache, database);
1018        }
1019      h = XHASH_TABLE (query_cache);
1020      i = hash_lookup (h, key, &hash_code);
1021      if (i >= 0)
1022        return HASH_VALUE (h, i);
1023    
1024    quark_name = parse_resource_name (&name);    quark_name = parse_resource_name (&name);
1025    if (*name != '\0')    if (*name != '\0')
# Line 1009  xrm_get_resource (database, name, class) Line 1038  xrm_get_resource (database, name, class)
1038    if (nn != nc)    if (nn != nc)
1039      return Qnil;      return Qnil;
1040    else    else
1041      return xrm_q_get_resource (database, quark_name, quark_class);      {
1042          tmp = xrm_q_get_resource (database, quark_name, quark_class);
1043          hash_put (h, key, tmp, hash_code);
1044          return tmp;
1045        }
1046  }  }
1047    
1048  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26