[gnome-builder] diagnostic: add ide_diagnostic_hash()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] diagnostic: add ide_diagnostic_hash()
- Date: Sun, 16 Oct 2016 06:19:07 +0000 (UTC)
commit 87c56f09b5f1e2452a0f92f35cdbe8ccbfe67862
Author: Christian Hergert <chergert redhat com>
Date: Sat Oct 15 23:07:13 2016 -0700
diagnostic: add ide_diagnostic_hash()
This can be helpful to deduplicate diagnostics that might be similar but
coming from multiple build targets.
libide/diagnostics/ide-diagnostic.c | 20 ++++++++++++++++++++
libide/diagnostics/ide-diagnostic.h | 2 ++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/libide/diagnostics/ide-diagnostic.c b/libide/diagnostics/ide-diagnostic.c
index 015b26c..589576a 100644
--- a/libide/diagnostics/ide-diagnostic.c
+++ b/libide/diagnostics/ide-diagnostic.c
@@ -37,8 +37,28 @@ struct _IdeDiagnostic
IdeSourceLocation *location;
GPtrArray *fixits;
GPtrArray *ranges;
+ guint hash;
};
+guint
+ide_diagnostic_hash (IdeDiagnostic *self)
+{
+ guint hash = self->hash;
+
+ if (hash == 0)
+ {
+ hash ^= g_str_hash (self->text ?: "");
+ if (self->location)
+ hash ^= ide_source_location_hash (self->location);
+ if (self->fixits)
+ hash ^= g_int_hash (&self->fixits->len);
+ if (self->ranges)
+ hash ^= g_int_hash (&self->ranges->len);
+ }
+
+ return hash;
+}
+
IdeDiagnostic *
ide_diagnostic_ref (IdeDiagnostic *self)
{
diff --git a/libide/diagnostics/ide-diagnostic.h b/libide/diagnostics/ide-diagnostic.h
index 54503ab..a46e90e 100644
--- a/libide/diagnostics/ide-diagnostic.h
+++ b/libide/diagnostics/ide-diagnostic.h
@@ -60,6 +60,8 @@ void ide_diagnostic_take_range (IdeDiagnostic
IdeSourceRange *range);
gint ide_diagnostic_compare (const IdeDiagnostic *a,
const IdeDiagnostic *b);
+guint ide_diagnostic_hash (IdeDiagnostic *self);
+
const gchar *ide_diagnostic_severity_to_string (IdeDiagnosticSeverity severity);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]