myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit c82ef972c8885e03f8f9c882b97a1d75cf223273
parent bd88f085113d43c65e0d560ff4dc7e9260985c3e
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Thu, 31 Mar 2016 11:11:02 +0200

Simplify keys lookup.

Diffstat:
Mmyadm.c | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/myadm.c b/myadm.c @@ -527,7 +527,6 @@ reload(const Arg *arg) { void run(void) { Key *k; - unsigned int i; int code; while(running) { @@ -536,9 +535,9 @@ run(void) { if(code < 0) continue; k = NULL; - for(i = 0; i < LENGTH(keys); ++i) - if(iscurmode(keys[i].mode) && keys[i].modkey == code) - k = &keys[i]; + for(k = keys; k; k++) + if(iscurmode(k->mode) && k->modkey == code) + break; if(k) { ui_set("status", ""); k->func(&k->arg); @@ -720,16 +719,16 @@ viewdblist_show(void) { mysql_fillview(res, 0); ui_listview(selview->items, NULL); } - mysql_free_result(res); ui_set("title", "Databases in `%s`", dbhost); ui_set("info", "%d DB(s)", selview->nitems); + mysql_free_result(res); } void viewprev(const Arg *arg) { View *v; - if(!selview->next) + if(!(selview && selview->next)) return; v = selview->next; cleanupview(selview);