From 6ee401049d475b2a2d9c859e6dbf8ff2750a1609 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 25 Nov 2018 00:21:13 -0500 Subject: [PATCH] Simplify sanitize set_object() / fix bots --- src/hb-machinery.hh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 56e279e6c..3717c4d33 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -259,17 +259,10 @@ struct hb_sanitize_context_t : inline void set_max_ops (int max_ops_) { max_ops = max_ops_; } - struct dummy_get_size_t - { inline unsigned int get_size (void) const { return 0; } }; - - template - inline void set_object (const T *obj = nullptr) + template + inline void set_object (const T *obj) { - this->start = this->blob->data; - this->end = this->start + this->blob->length; - assert (this->start <= this->end); /* Must not overflow. */ - - if (!obj) return; + reset_object (); const char *obj_start = (const char *) obj; const char *obj_end = (const char *) obj + obj->get_size (); @@ -284,9 +277,16 @@ struct hb_sanitize_context_t : } } + inline void reset_object (void) + { + this->start = this->blob->data; + this->end = this->start + this->blob->length; + assert (this->start <= this->end); /* Must not overflow. */ + } + inline void start_processing (void) { - set_object (); + reset_object (); this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR, (unsigned) HB_SANITIZE_MAX_OPS_MIN); this->edit_count = 0; @@ -482,7 +482,7 @@ struct hb_sanitize_context_t : struct hb_sanitize_with_object_t { - template + template inline hb_sanitize_with_object_t (hb_sanitize_context_t *c, const T& obj) : c (c) { @@ -490,7 +490,7 @@ struct hb_sanitize_with_object_t } inline ~hb_sanitize_with_object_t (void) { - c->set_object (); + c->reset_object (); } private: