GNU bug report logs - #25331
[PATCH] Unwrap single statement code blocks

Previous Next

Package: emacs;

Reported by: Chris Gregory <czipperz <at> gmail.com>

Date: Mon, 2 Jan 2017 08:20:01 UTC

Severity: wishlist

Tags: notabug, patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25331 in the body.
You can then email your comments to 25331 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25331; Package emacs. (Mon, 02 Jan 2017 08:20:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Chris Gregory <czipperz <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 02 Jan 2017 08:20:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Chris Gregory <czipperz <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Unwrap single statement code blocks
Date: Mon, 02 Jan 2017 00:19:26 -0800
This patch changes many blocks that look like:

    if (x)
      {
        statement;
      }

to

    if (x)
      statement;
-- 
Chris Gregory

diff --git a/src/ralloc.c b/src/ralloc.c
index 8a3d2b797f..0e1c2e41c5 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -178,10 +178,8 @@ find_heap (void *address)
   heap_ptr heap;
 
   for (heap = last_heap; heap; heap = heap->prev)
-    {
-      if (heap->start <= address && address <= heap->end)
-	return heap;
-    }
+    if (heap->start <= address && address <= heap->end)
+      return heap;
 
   return NIL_HEAP;
 }
@@ -212,10 +210,8 @@ obtain (void *address, size_t size)
 
   /* Find the heap that ADDRESS falls within.  */
   for (heap = last_heap; heap; heap = heap->prev)
-    {
-      if (heap->start <= address && address <= heap->end)
-	break;
-    }
+    if (heap->start <= address && address <= heap->end)
+      break;
 
   if (! heap)
     emacs_abort ();
@@ -295,10 +291,8 @@ relinquish (void)
      in all heaps which have extend beyond break_value at all.  */
 
   for (h = last_heap; h && break_value < h->end; h = h->prev)
-    {
-      excess += (char *) h->end - (char *) ((break_value < h->bloc_start)
-					    ? h->bloc_start : break_value);
-    }
+    excess += (char *) h->end - (char *) ((break_value < h->bloc_start)
+					  ? h->bloc_start : break_value);
 
   if (excess > extra_bytes * 2 && real_morecore (0) == last_heap->end)
     {
@@ -564,10 +558,8 @@ resize_bloc (bloc_ptr bloc, size_t size)
     return 1;
 
   for (heap = first_heap; heap != NIL_HEAP; heap = heap->next)
-    {
-      if (heap->bloc_start <= bloc->data && bloc->data <= heap->end)
-	break;
-    }
+    if (heap->bloc_start <= bloc->data && bloc->data <= heap->end)
+      break;
 
   if (heap == NIL_HEAP)
     emacs_abort ();
@@ -663,9 +655,7 @@ free_bloc (bloc_ptr bloc)
   resize_bloc (bloc, 0);
 
   if (bloc == first_bloc && bloc == last_bloc)
-    {
-      first_bloc = last_bloc = NIL_BLOC;
-    }
+    first_bloc = last_bloc = NIL_BLOC;
   else if (bloc == last_bloc)
     {
       last_bloc = bloc->prev;
@@ -858,10 +848,8 @@ r_alloc_sbrk (ptrdiff_t size)
 	}
 
       if ((char *) virtual_break_value + size < (char *) first_heap->start)
-	{
-	  /* We found an additional space below the first heap */
-	  first_heap->start = (void *) ((char *) virtual_break_value + size);
-	}
+	/* We found an additional space below the first heap */
+	first_heap->start = (void *) ((char *) virtual_break_value + size);
     }
 
   virtual_break_value = (void *) ((char *) address + size);
@@ -990,11 +978,8 @@ r_re_alloc (void **ptr, size_t size)
           else
 	    return NULL;
 	}
-      else
-	{
-	  if (! resize_bloc (bloc, MEM_ROUNDUP (size)))
-	    return NULL;
-        }
+      else if (! resize_bloc (bloc, MEM_ROUNDUP (size)))
+	return NULL;
     }
   return *ptr;
 }




Added tag(s) notabug. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 07 Jan 2017 08:32:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 25331 <at> debbugs.gnu.org and Chris Gregory <czipperz <at> gmail.com> Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 07 Jan 2017 08:32:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25331; Package emacs. (Sat, 07 Jan 2017 08:33:01 GMT) Full text and rfc822 format available.

Message #12 received at 25331 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Chris Gregory <czipperz <at> gmail.com>
Cc: 25331 <at> debbugs.gnu.org
Subject: Re: bug#25331: [PATCH] Unwrap single statement code blocks
Date: Sat, 07 Jan 2017 10:32:10 +0200
tags 25331 notabug
close 25331
thanks

> From: Chris Gregory <czipperz <at> gmail.com>
> Date: Mon, 02 Jan 2017 00:19:26 -0800
> 
> This patch changes many blocks that look like:
> 
>     if (x)
>       {
>         statement;
>       }
> 
> to
> 
>     if (x)
>       statement;

Thanks, but I think the original style is better, as it makes more
clear what is the body of the 'if'.

Also, this again changes ralloc.c on whose maintenance I'd rather not
spend any effort.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Feb 2017 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 193 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.