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 () |
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 |
} |
} |
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 |
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') |
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 |