Another easy 15-20% by not searching with no references

This commit is contained in:
Crzyrndm 2018-07-29 23:28:02 +12:00
parent e6a84c0cf0
commit 3ae31fadc3
2 changed files with 18 additions and 2 deletions

View File

@ -750,8 +750,7 @@ void cell::format(const class format new_format)
format().d_->references -= format().d_->references > 0 ? 1 : 0; format().d_->references -= format().d_->references > 0 ? 1 : 0;
} }
++new_format.d_->references; d_->format_ = detail::reference(new_format.d_);
d_->format_ = new_format.d_;
} }
calendar cell::base_date() const calendar cell::base_date() const

View File

@ -419,6 +419,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -431,6 +432,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -443,6 +445,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -455,6 +458,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -467,6 +471,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -483,6 +488,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -495,6 +501,7 @@ struct stylesheet
if (pattern->references == 0) if (pattern->references == 0)
{ {
*pattern = new_format; *pattern = new_format;
return pattern;
} }
return find_or_create(new_format); return find_or_create(new_format);
} }
@ -577,5 +584,15 @@ struct stylesheet
std::vector<color> colors; std::vector<color> colors;
}; };
inline format_impl* reference(format_impl *impl)
{
++impl->references;
if (impl->references == 1)
{
impl = impl->parent->find_or_create(*impl);
}
return impl;
}
} // namespace detail } // namespace detail
} // namespace xlnt } // namespace xlnt