forked from github/server
reduce use of cb_items, because we want to remove it.
This commit is contained in:
parent
7249630e3c
commit
7ee6f0444d
|
@ -1146,22 +1146,24 @@ attrib_type at_showitem = {
|
|||
static int add_itemname_cb(const void * match, const void * key, size_t keylen, void *data)
|
||||
{
|
||||
struct locale * lang = (struct locale *)data;
|
||||
int i = locale_index(lang);
|
||||
critbit_tree * cb = inames+i;
|
||||
item_type *itype;
|
||||
critbit_tree * cb = inames + locale_index(lang);
|
||||
resource_type *rtype;
|
||||
|
||||
cb_get_kv(match, &itype, sizeof(itype));
|
||||
for (i = 0; i!=2;++i) {
|
||||
cb_get_kv(match, &rtype, sizeof(rtype));
|
||||
if (rtype->itype) {
|
||||
int i;
|
||||
for (i = 0; i != 2; ++i) {
|
||||
char buffer[128];
|
||||
const char * name = locale_string(lang, itype->rtype->_name[i]);
|
||||
const char * name = locale_string(lang, rtype->_name[i]);
|
||||
|
||||
if (name && transliterate(buffer, sizeof(buffer), name)) {
|
||||
size_t len = strlen(buffer);
|
||||
assert(len+sizeof(itype)<sizeof(buffer));
|
||||
len = cb_new_kv(buffer, len, &itype, sizeof(itype), buffer);
|
||||
assert(len + sizeof(rtype->itype) < sizeof(buffer));
|
||||
len = cb_new_kv(buffer, len, &rtype->itype, sizeof(rtype->itype), buffer);
|
||||
cb_insert(cb, buffer, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1175,7 +1177,7 @@ const item_type *finditemtype(const char *name, const struct locale *lang)
|
|||
const void * match;
|
||||
if (!cb->root) {
|
||||
/* first-time initialization of item names for this locale */
|
||||
cb_foreach(&cb_items, "", 0, add_itemname_cb, (void *)lang);
|
||||
cb_foreach(&cb_resources, "", 0, add_itemname_cb, (void *)lang);
|
||||
}
|
||||
if (cb_find_prefix(cb, buffer, strlen(buffer), &match, 1, 0)) {
|
||||
const item_type * itype = 0;
|
||||
|
|
Loading…
Reference in New Issue