summaryrefslogtreecommitdiff
path: root/src/arch/operand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/operand.c')
-rw-r--r--src/arch/operand.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/arch/operand.c b/src/arch/operand.c
index ec970ea..1ec4e4f 100644
--- a/src/arch/operand.c
+++ b/src/arch/operand.c
@@ -24,11 +24,13 @@
#include "operand.h"
+#include <assert.h>
#include <malloc.h>
#include <string.h>
#include "operand-int.h"
+#include "../common/sort.h"
@@ -59,8 +61,8 @@ static void g_arch_operand_inc_references(GArchOperand *);
/* Décrémente le compteur de partage. */
static void g_arch_operand_dec_references(GArchOperand *);
-/* Indique l'objet partagé correspond à une description donnée. */
-static gboolean g_arch_operand_compare_info(const GArchOperand *, const void *);
+/* Compare de façon accélérée un opérande avec un autre. */
+static int g_arch_operand_quickly_compare(const GArchOperand **, const GArchOperand **);
/* Indique le type défini pour un opérande d'architecture. */
@@ -131,8 +133,7 @@ static void g_arch_operand_interface_init(GSharedInstanceInterface *iface)
iface->inc_ref = (inc_shared_ref_fc)g_arch_operand_inc_references;
iface->dec_ref = (dec_shared_ref_fc)g_arch_operand_dec_references;
- iface->cmp_info = (compare_shared_info_fc)g_arch_operand_compare_info;
- iface->is_equal = (is_shared_equal_fc)g_arch_operand_compare;
+ iface->qck_cmp = (qck_compare_shared_fc)g_arch_operand_quickly_compare;
}
@@ -260,22 +261,22 @@ static void g_arch_operand_dec_references(GArchOperand *operand)
/******************************************************************************
* *
-* Paramètres : operand = objet partagé à consulter. *
-* info = compilation de d'information à analyser. *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
* *
-* Description : Indique l'objet partagé correspond à une description donnée. *
+* Description : Compare de façon accélérée un opérande avec un autre. *
* *
-* Retour : true si les détails centraux sont partagés, false sinon. *
+* Retour : Bilan de la comparaison. *
* *
* Remarques : - *
* *
******************************************************************************/
-static gboolean g_arch_operand_compare_info(const GArchOperand *operand, const void *info)
+static int g_arch_operand_quickly_compare(const GArchOperand **a, const GArchOperand **b)
{
- bool result; /* Bilan à retourner */
+ int result; /* Bilan à faire remonter */
- result = G_ARCH_OPERAND_GET_CLASS(operand)->cmp_info(G_SHARED_INSTANCE(operand), info);
+ result = G_ARCH_OPERAND_GET_CLASS(*a)->compare(a, b);
return result;
@@ -295,14 +296,21 @@ static gboolean g_arch_operand_compare_info(const GArchOperand *operand, const v
* *
******************************************************************************/
-bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b)
+int g_arch_operand_compare(const GArchOperand * const *a, const GArchOperand * const *b)
{
- bool result; /* Bilan à faire remonter */
+ int result; /* Bilan à faire remonter */
+ GType type_a; /* Type de l'object A */
+ GType type_b; /* Type de l'object B */
+
+ type_a = G_OBJECT_TYPE(G_OBJECT(*a));
+ type_b = G_OBJECT_TYPE(G_OBJECT(*b));
+
+ assert(sizeof(GType) <= sizeof(unsigned long));
- result = (G_OBJECT_TYPE(G_OBJECT(a)) == G_OBJECT_TYPE(G_OBJECT(b)));
+ result = sort_unsigned_long(type_a, type_b);
- if (result)
- result = G_ARCH_OPERAND_GET_CLASS(a)->compare(a, b);
+ if (result == 0)
+ result = G_ARCH_OPERAND_GET_CLASS(*a)->compare(a, b);
return result;