emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112046: * region-cache.c (find_cache


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112046: * region-cache.c (find_cache_boundary, move_cache_gap)
Date: Fri, 15 Mar 2013 11:23:49 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112046
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2013-03-15 11:23:49 +0400
message:
  * region-cache.c (find_cache_boundary, move_cache_gap)
  (insert_cache_boundary, delete_cache_boundaries, set_cache_region):
  Simplify debugging check and convert to eassert.  Adjust comment.
  (pp_cache): Put under ENABLE_CHECKING.
modified:
  src/ChangeLog
  src/region-cache.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-03-14 17:37:51 +0000
+++ b/src/ChangeLog     2013-03-15 07:23:49 +0000
@@ -1,3 +1,10 @@
+2013-03-15  Dmitry Antipov  <address@hidden>
+
+       * region-cache.c (find_cache_boundary, move_cache_gap)
+       (insert_cache_boundary, delete_cache_boundaries, set_cache_region):
+       Simplify debugging check and convert to eassert.  Adjust comment.
+       (pp_cache): Put under ENABLE_CHECKING.
+
 2013-03-14  Eli Zaretskii  <address@hidden>
 
        * w32term.c (w32_read_socket) <WM_WINDOWPOSCHANGED>: Remove old

=== modified file 'src/region-cache.c'
--- a/src/region-cache.c        2013-03-08 21:37:41 +0000
+++ b/src/region-cache.c        2013-03-15 07:23:49 +0000
@@ -190,10 +190,9 @@
     }
 
   /* Some testing.  */
-  if (BOUNDARY_POS (c, low) > pos
-      || (low + 1 < c->cache_len
-          && BOUNDARY_POS (c, low + 1) <= pos))
-      emacs_abort ();
+  eassert (!(BOUNDARY_POS (c, low) > pos
+            || (low + 1 < c->cache_len
+                && BOUNDARY_POS (c, low + 1) <= pos)));
 
   return low;
 }
@@ -214,14 +213,9 @@
   ptrdiff_t buffer_beg = c->buffer_beg;
   ptrdiff_t buffer_end = c->buffer_end;
 
-  if (pos < 0
-      || pos > c->cache_len)
-    emacs_abort ();
-
   /* We mustn't ever try to put the gap before the dummy start
      boundary.  That must always be start-relative.  */
-  if (pos == 0)
-    emacs_abort ();
+  eassert (0 < pos && pos <= c->cache_len);
 
   /* Need we move the gap right?  */
   while (gap_start < pos)
@@ -288,26 +282,19 @@
 insert_cache_boundary (struct region_cache *c, ptrdiff_t i, ptrdiff_t pos,
                       int value)
 {
-  /* i must be a valid cache index.  */
-  if (i < 0 || i > c->cache_len)
-    emacs_abort ();
-
-  /* We must never want to insert something before the dummy first
-     boundary.  */
-  if (i == 0)
-    emacs_abort ();
+  /* I must be a valid cache index, and we must never want
+     to insert something before the dummy first boundary.  */
+  eassert (0 < i && i <= c->cache_len);
 
   /* We must only be inserting things in order.  */
-  if (! (BOUNDARY_POS (c, i - 1) < pos
-         && (i == c->cache_len
-             || pos < BOUNDARY_POS (c, i))))
-    emacs_abort ();
+  eassert ((BOUNDARY_POS (c, i - 1) < pos
+           && (i == c->cache_len
+               || pos < BOUNDARY_POS (c, i))));
 
   /* The value must be different from the ones around it.  However, we
      temporarily create boundaries that establish the same value as
      the subsequent boundary, so we're not going to flag that case.  */
-  if (BOUNDARY_VALUE (c, i - 1) == value)
-    emacs_abort ();
+  eassert (BOUNDARY_VALUE (c, i - 1) != value);
 
   move_cache_gap (c, i, 1);
 
@@ -328,18 +315,13 @@
   ptrdiff_t len = end - start;
 
   /* Gotta be in range.  */
-  if (start < 0
-      || end > c->cache_len)
-    emacs_abort ();
+  eassert (0 <= start && end <= c->cache_len);
 
   /* Gotta be in order.  */
-  if (start > end)
-    emacs_abort ();
+  eassert (start <= end);
 
   /* Can't delete the dummy entry.  */
-  if (start == 0
-      && end >= 1)
-    emacs_abort ();
+  eassert (!(start == 0 && end >= 1));
 
   /* Minimize gap motion.  If we're deleting nothing, do nothing.  */
   if (len == 0)
@@ -378,11 +360,8 @@
 set_cache_region (struct region_cache *c,
                  ptrdiff_t start, ptrdiff_t end, int value)
 {
-  if (start > end)
-    emacs_abort ();
-  if (start < c->buffer_beg
-      || end   > c->buffer_end)
-    emacs_abort ();
+  eassert (start <= end);
+  eassert (c->buffer_beg <= start && end <= c->buffer_end);
 
   /* Eliminate this case; then we can assume that start and end-1 are
      both the locations of real characters in the buffer.  */
@@ -772,7 +751,8 @@
   }
 }
 
-
+#ifdef ENABLE_CHECKING
+
 /* Debugging: pretty-print a cache to the standard error output.  */
 
 void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE;
@@ -803,3 +783,5 @@
       fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i));
     }
 }
+
+#endif /* ENABLE_CHECKING */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]