From e4856cf8098b9741a910e7f7979096cf11d8fead Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Jul 2023 21:21:33 -0600 Subject: [PATCH] [sanitize] Only check trailing edge of ranges Assumptions... Speeds up Gulzar load_face_and_shape benchmark by 7%. --- src/hb-sanitize.hh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh index 9c355f21d..9440f34a1 100644 --- a/src/hb-sanitize.hh +++ b/src/hb-sanitize.hh @@ -268,8 +268,7 @@ struct hb_sanitize_context_t : unsigned int len) const { const char *p = (const char *) base; - bool ok = (uintptr_t) (p - this->start) <= this->length && - (unsigned int) (this->end - p) >= len && + bool ok = (intptr_t) (this->end - p) >= (intptr_t) len && ((this->max_ops -= len) > 0); DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, @@ -288,8 +287,7 @@ struct hb_sanitize_context_t : unsigned int len) const { const char *p = (const char *) base; - bool ok = ((uintptr_t) (p - this->start) <= this->length && - (unsigned int) (this->end - p) >= len); + bool ok = (intptr_t) (this->end - p) >= (intptr_t) len; DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, "check_range_fast [%p..%p]"