mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 08:45:59 +01:00
Avoid explicit iterator
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
324d88100d
commit
bfdd4be4b2
2 changed files with 10 additions and 19 deletions
|
@ -529,14 +529,9 @@ sqlite_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* ju
|
|||
return true;
|
||||
}
|
||||
|
||||
girara_list_iterator_t* cur = girara_list_iterator(jumplist);
|
||||
bool status = true;
|
||||
|
||||
while (true) {
|
||||
zathura_jump_t* jump = girara_list_iterator_data(cur);
|
||||
|
||||
GIRARA_LIST_FOREACH_BODY(jumplist, zathura_jump_t*, jump,
|
||||
stmt = prepare_statement(priv->session, SQL_INSERT_JUMP);
|
||||
|
||||
if (stmt == NULL) {
|
||||
status = false;
|
||||
break;
|
||||
|
@ -546,7 +541,6 @@ sqlite_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* ju
|
|||
sqlite3_bind_int(stmt, 2, jump->page) != SQLITE_OK ||
|
||||
sqlite3_bind_double(stmt, 3, jump->x) != SQLITE_OK ||
|
||||
sqlite3_bind_double(stmt, 4, jump->y) != SQLITE_OK) {
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
girara_error("Failed to bind arguments.");
|
||||
status = false;
|
||||
|
@ -560,15 +554,7 @@ sqlite_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* ju
|
|||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (girara_list_iterator_has_next(cur) == true) {
|
||||
girara_list_iterator_next(cur);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
girara_list_iterator_free(cur);
|
||||
);
|
||||
|
||||
if (status == false) {
|
||||
sqlite3_exec(priv->session, "ROLLBACK;", NULL, 0, NULL);
|
||||
|
|
|
@ -281,13 +281,18 @@ plugin_mapping_new(zathura_plugin_manager_t* plugin_manager, const gchar* type,
|
|||
g_return_val_if_fail(type != NULL, false);
|
||||
g_return_val_if_fail(plugin != NULL, false);
|
||||
|
||||
GIRARA_LIST_FOREACH_BODY_WITH_ITER(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, iter, mapping,
|
||||
bool already_registered = false;
|
||||
GIRARA_LIST_FOREACH_BODY(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, mapping,
|
||||
if (g_content_type_equals(type, mapping->type)) {
|
||||
girara_list_iterator_free(iter);
|
||||
return false;
|
||||
already_registered = true;
|
||||
break;
|
||||
}
|
||||
);
|
||||
|
||||
if (already_registered == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
zathura_type_plugin_mapping_t* mapping = g_try_malloc0(sizeof(zathura_type_plugin_mapping_t));
|
||||
if (mapping == NULL) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue