added constexpr hash based enum for faster switch on attributes and node names

This commit is contained in:
2017-01-27 22:09:37 +00:00
parent d413e49821
commit 7436706b37
3 changed files with 81 additions and 57 deletions

View File

@@ -21,7 +21,7 @@ void Node::update_internal(glm::vec2 origin)
m_clip = glm::vec4(m_pos, m_size);
else
m_clip = rect_intersection(glm::vec4(m_pos, m_size), parent->m_clip);
for (auto& c : children)
for (auto& c : m_children)
c.update_internal(m_pos);
}
@@ -165,7 +165,7 @@ void Node::load(const char* path)
m_file_info = tmp_info;
m_path = path;
children.clear();
m_children.clear();
YGNodeReset(y_node);
tinyxml2::XMLDocument xml;
@@ -177,10 +177,11 @@ void Node::load(const char* path)
void Node::load_internal(const tinyxml2::XMLElement* x_node)
{
m_name = x_node->Name();
auto attr = x_node->FirstAttribute();
while (attr)
{
parse_attributes(att::value(attr->Name()), attr);
parse_attributes((att::kAttribute)att::const_hash(attr->Name()), attr);
attr = attr->Next();
}
@@ -188,8 +189,8 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
while (x_child)
{
//Node n;
children.emplace_back();
auto& n = children.back();
m_children.emplace_back();
auto& n = m_children.back();
n.parent = this;
YGNodeInsertChild(y_node, n.y_node, YGNodeGetChildCount(y_node));
n.load_internal(x_child);