[gnome-builder/wip/chergert/bug1: 100/101] debugger: tweak comparison of breakpoints



commit 5fcd6d5b39b138f35ffc83e1fa37c33323899887
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 1 12:51:06 2017 -0700

    debugger: tweak comparison of breakpoints
    
    Use pointer comparison first, then fallbacks. Only use pointer comparison
    if the breakpoint has not yet been created.

 libide/debugger/ide-debugger-breakpoint.c  |    9 +++++++++
 libide/debugger/ide-debugger-breakpoints.c |    5 +----
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libide/debugger/ide-debugger-breakpoint.c b/libide/debugger/ide-debugger-breakpoint.c
index fd87e3b..c55e232 100644
--- a/libide/debugger/ide-debugger-breakpoint.c
+++ b/libide/debugger/ide-debugger-breakpoint.c
@@ -939,6 +939,15 @@ ide_debugger_breakpoint_compare (IdeDebuggerBreakpoint *a,
   IdeDebuggerBreakpointPrivate *priv_a = ide_debugger_breakpoint_get_instance_private (a);
   IdeDebuggerBreakpointPrivate *priv_b = ide_debugger_breakpoint_get_instance_private (b);
 
+  if (a == b)
+    return 0;
+
+  /* Rely on pointer comparison for breakpoints that
+   * don't yet have an identifier.
+   */
+  if (priv_a->id == NULL && priv_b->id == NULL)
+    return FALSE;
+
   if (priv_a->id && priv_b->id)
     {
       if (g_ascii_isdigit (*priv_a->id) && g_ascii_isdigit (*priv_b->id))
diff --git a/libide/debugger/ide-debugger-breakpoints.c b/libide/debugger/ide-debugger-breakpoints.c
index ab67360..cc6b675 100644
--- a/libide/debugger/ide-debugger-breakpoints.c
+++ b/libide/debugger/ide-debugger-breakpoints.c
@@ -344,10 +344,7 @@ _ide_debugger_breakpoints_remove (IdeDebuggerBreakpoints *self,
         {
           const LineInfo *info = &g_array_index (self->lines, LineInfo, i);
 
-          /* FIXME: Maybe we should use ide_debugger_breakpoint_compare() here
-           *        and ensure that it falls back to file+line/function compare.
-           */
-          if (info->breakpoint == breakpoint)
+          if (ide_debugger_breakpoint_compare (breakpoint, info->breakpoint) == 0)
             {
               g_array_remove_index (self->lines, i);
               g_signal_emit (self, signals [CHANGED], 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]