Rename cache{Prefix,Substr} to cache{Complete,Search}

weechat-hashes
June McEnroe 2022-07-30 18:55:09 -04:00
parent 14a6486b9b
commit b373a5c091
5 changed files with 11 additions and 11 deletions

View File

@ -130,7 +130,7 @@ enum Color cacheColor(uint id, const char *key) {
return (node ? node->color : Default); return (node ? node->color : Default);
} }
const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix) { const char *cacheComplete(struct Cursor *curs, uint id, const char *prefix) {
size_t len = strlen(prefix); size_t len = strlen(prefix);
if (curs->gen != gen) curs->node = NULL; if (curs->gen != gen) curs->node = NULL;
for ( for (
@ -145,7 +145,7 @@ const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix) {
return NULL; return NULL;
} }
const char *cacheSubstr(struct Cursor *curs, uint id, const char *substr) { const char *cacheSearch(struct Cursor *curs, uint id, const char *substr) {
if (curs->gen != gen) curs->node = NULL; if (curs->gen != gen) curs->node = NULL;
for ( for (
curs->gen = gen, curs->node = (curs->node ? curs->node->next : head); curs->gen = gen, curs->node = (curs->node ? curs->node->next : head);

4
chat.h
View File

@ -404,8 +404,8 @@ void cacheInsert(bool touch, uint id, const char *key);
void cacheInsertColor(bool touch, uint id, const char *key, enum Color color); void cacheInsertColor(bool touch, uint id, const char *key, enum Color color);
void cacheReplace(bool touch, const char *old, const char *new); void cacheReplace(bool touch, const char *old, const char *new);
enum Color cacheColor(uint id, const char *key); enum Color cacheColor(uint id, const char *key);
const char *cachePrefix(struct Cursor *curs, uint id, const char *prefix); const char *cacheComplete(struct Cursor *curs, uint id, const char *prefix);
const char *cacheSubstr(struct Cursor *curs, uint id, const char *substr); const char *cacheSearch(struct Cursor *curs, uint id, const char *substr);
uint cacheID(struct Cursor *curs, const char *key); uint cacheID(struct Cursor *curs, const char *key);
void cacheAccept(struct Cursor *curs); void cacheAccept(struct Cursor *curs);
void cacheReject(struct Cursor *curs); void cacheReject(struct Cursor *curs);

View File

@ -397,7 +397,7 @@ static void commandWindow(uint id, char *params) {
return; return;
} }
struct Cursor curs = {0}; struct Cursor curs = {0};
for (const char *match; (match = cacheSubstr(&curs, None, params));) { for (const char *match; (match = cacheSearch(&curs, None, params));) {
id = idFind(match); id = idFind(match);
if (!id) continue; if (!id) continue;
cacheAccept(&curs); cacheAccept(&curs);
@ -672,8 +672,8 @@ void command(uint id, char *input) {
struct Cursor curs = {0}; struct Cursor curs = {0};
const char *cmd = strsep(&input, " "); const char *cmd = strsep(&input, " ");
const char *unique = cachePrefix(&curs, None, cmd); const char *unique = cacheComplete(&curs, None, cmd);
if (unique && !cachePrefix(&curs, None, cmd)) { if (unique && !cacheComplete(&curs, None, cmd)) {
cmd = unique; cmd = unique;
} }

View File

@ -641,7 +641,7 @@ static void handleReplyNoTopic(struct Message *msg) {
static void topicCache(uint id, const char *topic) { static void topicCache(uint id, const char *topic) {
char buf[512]; char buf[512];
struct Cursor curs = {0}; struct Cursor curs = {0};
const char *prev = cachePrefix(&curs, id, "/topic "); const char *prev = cacheComplete(&curs, id, "/topic ");
if (prev) { if (prev) {
snprintf(buf, sizeof(buf), "%s", prev); snprintf(buf, sizeof(buf), "%s", prev);
cacheRemove(id, buf); cacheRemove(id, buf);
@ -720,7 +720,7 @@ static void handleTopic(struct Message *msg) {
} }
struct Cursor curs = {0}; struct Cursor curs = {0};
const char *prev = cachePrefix(&curs, id, "/topic "); const char *prev = cacheComplete(&curs, id, "/topic ");
if (prev) { if (prev) {
prev += 7; prev += 7;
} else { } else {

View File

@ -333,9 +333,9 @@ static int tabComplete(struct Edit *e, uint id) {
tab.suffix = true; tab.suffix = true;
} }
const char *comp = cachePrefix(&tab.curs, id, tab.pre); const char *comp = cacheComplete(&tab.curs, id, tab.pre);
if (!comp) { if (!comp) {
comp = cachePrefix(&tab.curs, id, tab.pre); comp = cacheComplete(&tab.curs, id, tab.pre);
tab.suffix ^= true; tab.suffix ^= true;
} }
if (!comp) { if (!comp) {