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