Commit 104d269a by Aaron Leung

Keeping a registry of allocations.

parent e73dc124
...@@ -15,7 +15,7 @@ using std::endl; ...@@ -15,7 +15,7 @@ using std::endl;
namespace Sass { namespace Sass {
size_t Node::allocations = 0; size_t Node::allocations = 0;
Node Node::clone() const Node Node::clone(vector<vector<Node>*>& registry) const
{ {
Node n(*this); Node n(*this);
if (has_children) { if (has_children) {
...@@ -25,6 +25,7 @@ namespace Sass { ...@@ -25,6 +25,7 @@ namespace Sass {
for (int i = 0; i < size(); ++i) { for (int i = 0; i < size(); ++i) {
n << at(i).clone(); n << at(i).clone();
} }
registry.push_back(n.content.children);
} }
return n; return n;
} }
......
...@@ -199,12 +199,13 @@ namespace Sass { ...@@ -199,12 +199,13 @@ namespace Sass {
Node(Type t) // flags or booleans Node(Type t) // flags or booleans
{ clear(); type = t; } { clear(); type = t; }
Node(Type t, unsigned int ln, size_t s = 0) // nodes with children Node(Type t, vector<vector<Node>*>& registry, unsigned int ln, size_t s = 0) // nodes with children
{ {
clear(); clear();
type = t; type = t;
line_number = ln; line_number = ln;
content.children = new vector<Node>; content.children = new vector<Node>;
registry.push_back(content.children);
content.children->reserve(s); content.children->reserve(s);
has_children = true; has_children = true;
++allocations; ++allocations;
...@@ -236,12 +237,13 @@ namespace Sass { ...@@ -236,12 +237,13 @@ namespace Sass {
content.dimension.unit = tok.begin; content.dimension.unit = tok.begin;
} }
Node(unsigned int ln, double r, double g, double b, double a = 1.0) // colors Node(vector<vector<Node>*>& registry, unsigned int ln, double r, double g, double b, double a = 1.0) // colors
{ {
clear(); clear();
type = numeric_color; type = numeric_color;
line_number = ln; line_number = ln;
content.children = new vector<Node>; content.children = new vector<Node>;
registry.push_back(content.children);
content.children->reserve(4); content.children->reserve(4);
content.children->push_back(Node(ln, r)); content.children->push_back(Node(ln, r));
content.children->push_back(Node(ln, g)); content.children->push_back(Node(ln, g));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment