[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.
This commit is contained in:
Garret Rieger 2021-10-06 10:51:45 -07:00
parent 8cae8b653d
commit ff7a86e9b0
1 changed files with 3 additions and 36 deletions

View File

@ -129,33 +129,6 @@ struct graph_t
unsigned child; 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 * A topological sorting of an object graph. Ordered
* in reverse serialization order (first object in the * in reverse serialization order (first object in the
@ -196,14 +169,12 @@ struct graph_t
~graph_t () ~graph_t ()
{ {
vertices_.fini_deep (); vertices_.fini_deep ();
clone_buffers_.fini_deep ();
} }
bool in_error () const bool in_error () const
{ {
return !successful || return !successful ||
vertices_.in_error () || vertices_.in_error () ||
clone_buffers_.in_error () ||
num_roots_for_space_.in_error (); num_roots_for_space_.in_error ();
} }
@ -541,15 +512,12 @@ struct graph_t
auto* clone = vertices_.push (); auto* clone = vertices_.push ();
auto& child = vertices_[node_idx]; auto& child = vertices_[node_idx];
clone_buffer_t* buffer = clone_buffers_.push (); if (vertices_.in_error ()) {
if (vertices_.in_error ()
|| clone_buffers_.in_error ()
|| !check_success (buffer->copy (child.obj))) {
return -1; return -1;
} }
clone->obj.head = buffer->head; clone->obj.head = child.obj.head;
clone->obj.tail = buffer->tail; clone->obj.tail = child.obj.tail;
clone->distance = child.distance; clone->distance = child.distance;
clone->space = child.space; clone->space = child.space;
clone->parents.reset (); 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. // TODO(garretrieger): make private, will need to move most of offset overflow code into graph.
hb_vector_t<vertex_t> vertices_; hb_vector_t<vertex_t> vertices_;
private: private:
hb_vector_t<clone_buffer_t> clone_buffers_;
bool parents_invalid; bool parents_invalid;
bool distance_invalid; bool distance_invalid;
bool positions_invalid; bool positions_invalid;