[gnome-builder/wip/highlight] highlight: add some debug helpers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/highlight] highlight: add some debug helpers
- Date: Thu, 26 Mar 2015 21:08:31 +0000 (UTC)
commit 0aad9caead1dae317ff3a44f8d936801bbc2cc75
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 26 14:08:20 2015 -0700
highlight: add some debug helpers
libide/ide-highlight-index.c | 24 +++++++++++++++++++++++-
libide/ide-highlight-index.h | 1 +
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-highlight-index.c b/libide/ide-highlight-index.c
index ff80531..261c253 100644
--- a/libide/ide-highlight-index.c
+++ b/libide/ide-highlight-index.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
#include <sys/user.h>
#include "ide-highlight-index.h"
@@ -26,6 +27,11 @@ G_DEFINE_BOXED_TYPE (IdeHighlightIndex, ide_highlight_index,
struct _IdeHighlightIndex
{
volatile gint ref_count;
+
+ /* For debugging info */
+ guint count;
+ gsize chunk_size;
+
GStringChunk *strings;
GHashTable *index;
};
@@ -51,12 +57,17 @@ ide_highlight_index_insert (IdeHighlightIndex *self,
gchar *key;
g_assert (self);
- g_assert (word);
g_assert (kind != IDE_HIGHLIGHT_KIND_NONE);
+ if (word == NULL || word[0] == '\0')
+ return;
+
if (g_hash_table_contains (self->index, word))
return;
+ self->count++;
+ self->chunk_size += strlen (word) + 1;
+
key = g_string_chunk_insert (self->strings, word);
g_hash_table_insert (self->index, key, GINT_TO_POINTER (kind));
}
@@ -99,3 +110,14 @@ ide_highlight_index_unref (IdeHighlightIndex *self)
g_free (self);
}
}
+
+void
+ide_highlight_index_dump (IdeHighlightIndex *self)
+{
+ g_assert (self);
+
+ g_printerr ("IdeHighlightIndex at %p\n"
+ " Number of items in Index: %u\n"
+ " String Chunk Size (Estimate): %"G_GSIZE_FORMAT"\n",
+ self, self->count, self->chunk_size);
+}
diff --git a/libide/ide-highlight-index.h b/libide/ide-highlight-index.h
index c36d173..ab95c00 100644
--- a/libide/ide-highlight-index.h
+++ b/libide/ide-highlight-index.h
@@ -36,6 +36,7 @@ void ide_highlight_index_insert (IdeHighlightIndex *self,
IdeHighlightKind kind);
IdeHighlightKind ide_highlight_index_lookup (IdeHighlightIndex *self,
const gchar *word);
+void ide_highlight_index_dump (IdeHighlightIndex *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeHighlightIndex, ide_highlight_index_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]