From ff7a86e9b06f7c9b4c82fb931d681b08be1e0b27 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 6 Oct 2021 10:51:45 -0700 Subject: [PATCH] [repacker] remove clone buffer, they are unnessecary. When nodes are duplicated it's fine to just reuse head, tail from the node being cloned since we don't modify the contents. --- src/hb-repacker.hh | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index df4efa80f..1320b4220 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -129,33 +129,6 @@ struct graph_t unsigned child; }; - struct clone_buffer_t - { - clone_buffer_t () : head (nullptr), tail (nullptr) {} - - bool copy (const hb_serialize_context_t::object_t& object) - { - fini (); - unsigned size = object.tail - object.head; - head = (char*) hb_malloc (size); - if (!head) return false; - - memcpy (head, object.head, size); - tail = head + size; - return true; - } - - char* head; - char* tail; - - void fini () - { - if (!head) return; - hb_free (head); - head = nullptr; - } - }; - /* * A topological sorting of an object graph. Ordered * in reverse serialization order (first object in the @@ -196,14 +169,12 @@ struct graph_t ~graph_t () { vertices_.fini_deep (); - clone_buffers_.fini_deep (); } bool in_error () const { return !successful || vertices_.in_error () || - clone_buffers_.in_error () || num_roots_for_space_.in_error (); } @@ -541,15 +512,12 @@ struct graph_t auto* clone = vertices_.push (); auto& child = vertices_[node_idx]; - clone_buffer_t* buffer = clone_buffers_.push (); - if (vertices_.in_error () - || clone_buffers_.in_error () - || !check_success (buffer->copy (child.obj))) { + if (vertices_.in_error ()) { return -1; } - clone->obj.head = buffer->head; - clone->obj.tail = buffer->tail; + clone->obj.head = child.obj.head; + clone->obj.tail = child.obj.tail; clone->distance = child.distance; clone->space = child.space; clone->parents.reset (); @@ -1057,7 +1025,6 @@ struct graph_t // TODO(garretrieger): make private, will need to move most of offset overflow code into graph. hb_vector_t vertices_; private: - hb_vector_t clone_buffers_; bool parents_invalid; bool distance_invalid; bool positions_invalid;