This moves three "if" conditions out of line from find_offset()
function, which is responsible for finding the matching place in
the preimage to apply the patch. There is no change in the
logic of the program.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-apply.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 15432b6..2c052f8 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1437,6 +1437,17 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
}
}
+static int match_fragment(const char *buf, unsigned long size,
+ unsigned long try,
+ const char *fragment, unsigned long fragsize)
+{
+ if (try + fragsize > size)
+ return 0;
+ if (memcmp(buf + try, fragment, fragsize))
+ return 0;
+ return 1;
+}
+
static int find_offset(const char *buf, unsigned long size,
const char *fragment, unsigned long fragsize,
int line, int *lines)
@@ -1461,8 +1472,7 @@ static int find_offset(const char *buf, unsigned long size,
}
/* Exact line number? */
- if ((start + fragsize <= size) &&
- !memcmp(buf + start, fragment, fragsize))
+ if (match_fragment(buf, size, start, fragment, fragsize))
return start;
/*
@@ -1494,9 +1504,7 @@ static int find_offset(const char *buf, unsigned long size,
try = forwards;
}
- if (try + fragsize > size)
- continue;
- if (memcmp(buf + try, fragment, fragsize))
+ if (!match_fragment(buf, size, try, fragment, fragsize))
continue;
n = (i >> 1)+1;
if (i & 1)
--
1.5.4.2.g41ac4
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| Faik Uygur | Re: Linux 2.6.21-rc1 |
| pageexec | Re: [stable] Linux 2.6.25.10 |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
git: | |
| Mark Lord | Re: 2.6.25-rc8: FTP transfer errors |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
