[gnome-builder/wip/gtk4-port] libide/code: add ide_location_equal()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/code: add ide_location_equal()
- Date: Fri, 20 May 2022 21:39:47 +0000 (UTC)
commit d0a2531a1d50ae9ce18c2863fc00909f2b99ca7b
Author: Christian Hergert <chergert redhat com>
Date: Fri May 20 14:36:24 2022 -0700
libide/code: add ide_location_equal()
src/libide/code/ide-location.c | 27 +++++++++++++++++++++++++++
src/libide/code/ide-location.h | 3 +++
2 files changed, 30 insertions(+)
---
diff --git a/src/libide/code/ide-location.c b/src/libide/code/ide-location.c
index 27c903af0..1903399de 100644
--- a/src/libide/code/ide-location.c
+++ b/src/libide/code/ide-location.c
@@ -501,3 +501,30 @@ ide_location_hash (IdeLocation *self)
return g_file_hash (priv->file) ^ g_int_hash (&priv->line) ^ g_int_hash (&priv->line_offset);
}
+
+gboolean
+ide_location_equal (IdeLocation *a,
+ IdeLocation *b)
+{
+ IdeLocationPrivate *a_priv = ide_location_get_instance_private (a);
+ IdeLocationPrivate *b_priv = ide_location_get_instance_private (b);
+
+ g_return_val_if_fail (!a || IDE_IS_LOCATION (a), FALSE);
+ g_return_val_if_fail (!b || IDE_IS_LOCATION (b), FALSE);
+
+ if (a == NULL || b == NULL)
+ return FALSE;
+
+ if (a_priv->file == NULL || b_priv->file == NULL)
+ return FALSE;
+
+ if (G_OBJECT_TYPE (a) != G_OBJECT_TYPE (b))
+ return FALSE;
+
+ if (!g_file_equal (a_priv->file, b_priv->file))
+ return FALSE;
+
+ return a_priv->line == b_priv->line &&
+ a_priv->line_offset == b_priv->line_offset &&
+ a_priv->offset == b_priv->offset;
+}
diff --git a/src/libide/code/ide-location.h b/src/libide/code/ide-location.h
index 1820a8027..c462d3bae 100644
--- a/src/libide/code/ide-location.h
+++ b/src/libide/code/ide-location.h
@@ -71,5 +71,8 @@ gboolean ide_location_compare (IdeLocation *a,
IdeLocation *b);
IDE_AVAILABLE_IN_3_32
guint ide_location_hash (IdeLocation *self);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_location_equal (IdeLocation *a,
+ IdeLocation *b);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]