summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSen Jiang <senj@google.com>2018-04-10 15:11:51 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-04-10 15:11:51 -0700
commit2ea72093fec95481a392fc7884558b230f970c54 (patch)
tree11da834207f4550a175063219e58c52ac89829e9
parentcbc5e6f179efc94133f773df7037e77155f7e3d0 (diff)
parentd1d34782a16f21d4f8564e691c4258c0097beec5 (diff)
downloadbsdiff-2ea72093fec95481a392fc7884558b230f970c54.tar.gz
Merge "Exit loop ealier when matching lastoffset." am: 365012ab68 am: aa1c9404c7
am: d1d34782a1 Change-Id: Icb32c479371d6de59ba957364c090e3ea2522495
-rw-r--r--bsdiff.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/bsdiff.cc b/bsdiff.cc
index c775bdf..8bb21b7 100644
--- a/bsdiff.cc
+++ b/bsdiff.cc
@@ -114,10 +114,9 @@ int bsdiff(const uint8_t* old_buf, size_t oldsize, const uint8_t* new_buf,
sai->SearchPrefix(new_buf + scan, newsize - scan, &len, &pos);
- for(;scsc<scan+len;scsc++)
- if((scsc+lastoffset<oldsize) &&
- (old_buf[scsc+lastoffset] == new_buf[scsc]))
- oldscore++;
+ for(;scsc<scan+len && scsc+lastoffset<oldsize;scsc++)
+ if(old_buf[scsc+lastoffset] == new_buf[scsc])
+ oldscore++;
if(((len==oldscore) && (len!=0)) ||
(len>oldscore+8 && len>=min_length)) break;