Linux-Dash Archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: dash@vger.kernel.org
Subject: Kill pgetc_macro
Date: Mon, 29 Sep 2014 17:08:50 +0800	[thread overview]
Message-ID: <20140929090850.GA1343@gondor.apana.org.au> (raw)

While looking at the backslash newline bug it occured to me that
pgetc_macro is vestigial and should be removed.  I've run some
speed tests on the result and the difference appears to be in the
noise.  But if anyone sees a big regression please let me know.

commit 339b9c0781cca7afb0964c6a655cda8ad9cf9fc2
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Mon Sep 29 17:05:53 2014 +0800

    [INPUT] Kill pgetc_macro
    
    pgetc_macro is identical to pgetc except that it's a macro and
    pgetc isn't.  Since there is very little performance difference
    on modern systems it's time to kill pgetc_macro.
    
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 7345144..0fbc514 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-09-29  Herbert Xu <herbert@gondor.apana.org.au>
+
+	* Kill pgetc_macro.
+
 2014-09-28  Herbert Xu <herbert@gondor.apana.org.au>
 
 	* Correctly handle test ! ! = !.
diff --git a/src/input.c b/src/input.c
index d31c45b..9e533a4 100644
--- a/src/input.c
+++ b/src/input.c
@@ -134,7 +134,10 @@ RESET {
 int
 pgetc(void)
 {
-	return pgetc_macro();
+	if (--parsenleft >= 0)
+		return (signed char)*parsenextc++;
+	else
+		return preadbuffer();
 }
 
 
@@ -147,7 +150,7 @@ pgetc2()
 {
 	int c;
 	do {
-		c = pgetc_macro();
+		c = pgetc();
 	} while (c == PEOA);
 	return c;
 }
diff --git a/src/input.h b/src/input.h
index 50a7797..775291b 100644
--- a/src/input.h
+++ b/src/input.h
@@ -61,6 +61,3 @@ void setinputstring(char *);
 void popfile(void);
 void popallfiles(void);
 void closescript(void);
-
-#define pgetc_macro() \
-	(--parsenleft >= 0 ? (signed char)*parsenextc++ : preadbuffer())
diff --git a/src/parser.c b/src/parser.c
index 572cbcd..c4eaae2 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -775,7 +775,7 @@ xxreadtoken(void)
 		setprompt(2);
 	}
 	for (;;) {	/* until token or start of word found */
-		c = pgetc_macro();
+		c = pgetc();
 		switch (c) {
 		case ' ': case '\t':
 		case PEOA:
@@ -1009,7 +1009,7 @@ quotemark:
 					USTPUTC(c, out);
 				}
 			}
-			c = pgetc_macro();
+			c = pgetc();
 		}
 	}
 endword:

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

                 reply	other threads:[~2014-09-29  9:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140929090850.GA1343@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).