1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

bptr.h: size optimizations.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-09-20 10:30:09 +02:00
parent 9579a51a8b
commit dc56c4e530

View File

@ -77,19 +77,31 @@ public:
private:
void checkNULL() const {
if (!ptr_)
if __acc_very_unlikely(!ptr_)
throwCantUnpack("unexpected NULL pointer; take care!");
}
void checkRange(size_t extra=0) const {
void checkRange() const {
size_t off = (const char *) ptr_ - (const char *) base_;
if (off > size_ || off + extra > size_)
if __acc_very_unlikely(off > size_)
throwCantUnpack("pointer out of range; take care!");
}
void checkStrict(size_t extra=0) const {
void checkRange(size_t extra) const {
size_t off = (const char *) ptr_ - (const char *) base_;
if __acc_very_unlikely(off > size_ || off + extra > size_)
throwCantUnpack("pointer out of range; take care!");
}
void checkStrict() const {
checkNULL();
checkRange();
}
void checkStrict(size_t extra) const {
checkNULL();
checkRange(extra);
}
void check(size_t extra=0) const {
void check() const {
if (ptr_) checkRange();
}
void check(size_t extra) const {
if (ptr_) checkRange(extra);
}