summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDungSaga <dungsaga@users.noreply.github.com>2021-10-18 13:16:03 +0100
committerBram Moolenaar <Bram@vim.org>2021-10-18 13:16:03 +0100
commit375c35a63fdb91e8db2a9965f94d56ae87135fff (patch)
tree95ec06f0511021fd9db3aef4174d173b4ce0c7f3
parente08aee60abc59f517d3e263fdb9ba4a0196d507c (diff)
patch 8.2.3533: inefficient code in xxdv8.2.3533
Problem: Inefficient code in xxd. Solution: Don't use "p" when "hextype" is non-zero. (closes #9013)
-rw-r--r--src/version.c2
-rw-r--r--src/xxd/xxd.c17
2 files changed, 8 insertions, 11 deletions
diff --git a/src/version.c b/src/version.c
index 53b902acac..b84aef5c6d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3533,
+/**/
3532,
/**/
3531,
diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c
index 4e352034ed..749df435d2 100644
--- a/src/xxd/xxd.c
+++ b/src/xxd/xxd.c
@@ -302,20 +302,15 @@ huntype(
ign_garb = 0;
- if (p >= cols)
+ if (!hextype && (p >= cols))
{
- if (!hextype)
+ if (n1 < 0)
{
- if (n1 < 0)
- {
- p = 0;
- continue;
- }
- want_off = (want_off << 4) | n1;
+ p = 0;
continue;
}
- else
- p = 0;
+ want_off = (want_off << 4) | n1;
+ continue;
}
if (base_off + want_off != have_off)
@@ -344,7 +339,7 @@ huntype(
have_off++;
want_off++;
n1 = -1;
- if ((++p >= cols) && !hextype)
+ if (!hextype && (++p >= cols))
{
/* skip the rest of the line as garbage */
n2 = -1;