Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/indent indent: remove confusing modulo from code_add...



details:   https://anonhg.NetBSD.org/src/rev/f9ffee806833
branches:  trunk
changeset: 1024636:f9ffee806833
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 30 10:59:07 2021 +0000

description:
indent: remove confusing modulo from code_add_decl_indent

The only effects of the modulo operation was to make indent slower and
to confuse human readers.

During the computation of the indentation, the main focus is on the
difference between the current indentation, as computed from the base
indentation and the current code, and the target indentation. All these
computations take opt.tabsize into account. When looking only at the
difference, whether or not a multiple of opt.tabsize is added does not
matter.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (31 lines):

diff -r b5b7fa948b9c -r f9ffee806833 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sat Oct 30 10:52:43 2021 +0000
+++ b/usr.bin/indent/indent.c   Sat Oct 30 10:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.182 2021/10/30 10:01:31 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.183 2021/10/30 10:59:07 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.182 2021/10/30 10:01:31 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.183 2021/10/30 10:59:07 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -610,9 +610,9 @@
      * get the tab math right for indentations that are not multiples of
      * tabsize
      */
-    if ((ps.ind_level * opt.indent_size) % opt.tabsize != 0) {
-       ind += (ps.ind_level * opt.indent_size) % opt.tabsize;
-       cur_decl_ind += (ps.ind_level * opt.indent_size) % opt.tabsize;
+    if (ps.ind_level * opt.indent_size != 0) {
+       ind += ps.ind_level * opt.indent_size;
+       cur_decl_ind += ps.ind_level * opt.indent_size;
     }
 
     if (tabs_to_var) {



Home | Main Index | Thread Index | Old Index