[gnome-builder] source-location: add ide_source_location_hash()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-location: add ide_source_location_hash()
- Date: Sun, 16 Oct 2016 06:19:02 +0000 (UTC)
commit 77685e56989a30596d5199c0a6ff0cccc44223e8
Author: Christian Hergert <chergert redhat com>
Date: Sat Oct 15 23:06:41 2016 -0700
source-location: add ide_source_location_hash()
libide/diagnostics/ide-source-location.c | 10 ++++++++++
libide/diagnostics/ide-source-location.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libide/diagnostics/ide-source-location.c b/libide/diagnostics/ide-source-location.c
index 2804b78..3780a76 100644
--- a/libide/diagnostics/ide-source-location.c
+++ b/libide/diagnostics/ide-source-location.c
@@ -205,9 +205,19 @@ ide_source_location_compare (const IdeSourceLocation *a,
if (0 != (ret = ide_file_compare (a->file, b->file)))
return ret;
}
+ else if (a->file)
+ return -1;
+ else if (b->file)
+ return 1;
if (0 != (ret = (gint)a->line - (gint)b->line))
return ret;
return (gint)a->line_offset - (gint)b->line_offset;
}
+
+guint
+ide_source_location_hash (IdeSourceLocation *self)
+{
+ return ide_file_hash (self->file) ^ g_int_hash (&self->line) ^ g_int_hash (&self->line_offset);
+}
diff --git a/libide/diagnostics/ide-source-location.h b/libide/diagnostics/ide-source-location.h
index ab56e18..1dad31b 100644
--- a/libide/diagnostics/ide-source-location.h
+++ b/libide/diagnostics/ide-source-location.h
@@ -41,6 +41,7 @@ IdeFile *ide_source_location_get_file (IdeSourceLocation
IdeUri *ide_source_location_get_uri (IdeSourceLocation *self);
gint ide_source_location_compare (const IdeSourceLocation *a,
const IdeSourceLocation *b);
+guint ide_source_location_hash (IdeSourceLocation *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeSourceLocation, ide_source_location_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]