summaryrefslogtreecommitdiff
path: root/plugins/dex/pool.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-01-27 18:48:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-01-27 18:48:58 (GMT)
commitc1ca03be00a4e975f89d30edfb72b57fb5612282 (patch)
tree4884513252458a261eb1290c93748b2bbbd98ff8 /plugins/dex/pool.c
parent1b3887c5609831bc2aee2f00f6a4d31d7406a225 (diff)
Created a huge optimization for the Dex format loading.
Diffstat (limited to 'plugins/dex/pool.c')
-rw-r--r--plugins/dex/pool.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index c24617a..d800e8f 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -251,6 +251,11 @@ bool g_dex_pool_load_all_string_symbols(GDexPool *pool, wgroup_id_t gid, GtkStat
gtk_status_stack_remove_activity(status, msg);
+ /* Insertion en tant que symboles */
+
+ if (result)
+ result = g_binary_format_add_symbols(G_BIN_FORMAT(pool->format), pool->strings, count);
+
return result;
}
@@ -367,7 +372,6 @@ GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *pool, uint32_t index)
const char *string; /* Chaîne de caractères liée */
GBinFormat *base; /* Autre version du format */
GBinSymbol *new; /* Nouveau symbol créé */
- bool inserted; /* Bilan d'une insertion */
result = NULL;
@@ -385,16 +389,10 @@ GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *pool, uint32_t index)
new = g_string_symbol_new_read_only(base, &range, SET_MUTF_8);
- g_string_symbol_build_label(G_STR_SYMBOL(new), base);
-
- g_object_ref(G_OBJECT(new));
- inserted = g_binary_format_add_symbol(base, new);
-
- if (inserted)
- pool->strings[index] = new;
+ if (new != NULL)
+ g_string_symbol_build_label(G_STR_SYMBOL(new), base);
- else
- g_object_unref(G_OBJECT(new));
+ pool->strings[index] = new;
}
@@ -1175,10 +1173,14 @@ bool g_dex_pool_load_all_classes(GDexPool *pool, wgroup_id_t gid, GtkStatusStack
uint32_t run_size; /* Volume réparti par exécution*/
GWorkQueue *queue; /* Gestionnaire de différés */
activity_id_t msg; /* Message de progression */
- guint i; /* Boucle de parcours */
+ guint i; /* Boucle de parcours #1 */
uint32_t begin; /* Début de bloc de traitement */
uint32_t end; /* Fin d'un bloc de traitement */
GDexLoading *loading; /* Tâche de chargement à lancer*/
+ GBinSymbol **symbols; /* Symboles présents à injecter*/
+ size_t scount; /* Quantité de ces symboles */
+ uint32_t j; /* Boucle de parcours #2 */
+ size_t k; /* Boucle de parcours #3 */
result = true;
@@ -1216,6 +1218,27 @@ bool g_dex_pool_load_all_classes(GDexPool *pool, wgroup_id_t gid, GtkStatusStack
gtk_status_stack_remove_activity(status, msg);
+ /* Insertion en tant que symboles */
+
+ if (result)
+ {
+ symbols = NULL;
+ scount = 0;
+
+ for (j = 0; j < count && result; j++)
+ result = g_dex_class_get_collect_symbols(pool->classes[j], &symbols, &scount);
+
+ if (result)
+ result = g_binary_format_add_symbols(G_BIN_FORMAT(pool->format), symbols, count);
+
+ for (k = 0; k < scount; k++)
+ g_object_unref(symbols[k]);
+
+ if (symbols != NULL)
+ free(symbols);
+
+ }
+
return result;
}