mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Optimise modifying a new format to reduce garbage collection runs
This commit is contained in:
parent
b4f695b3ea
commit
e6a84c0cf0
|
@ -416,7 +416,10 @@ struct stylesheet
|
||||||
{
|
{
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.style = style_name;
|
new_format.style = style_name;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +428,10 @@ struct stylesheet
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.alignment_id = find_or_add(alignments, new_alignment);
|
new_format.alignment_id = find_or_add(alignments, new_alignment);
|
||||||
new_format.alignment_applied = applied;
|
new_format.alignment_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +440,10 @@ struct stylesheet
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.border_id = find_or_add(borders, new_border);
|
new_format.border_id = find_or_add(borders, new_border);
|
||||||
new_format.border_applied = applied;
|
new_format.border_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +452,10 @@ struct stylesheet
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.fill_id = find_or_add(fills, new_fill);
|
new_format.fill_id = find_or_add(fills, new_fill);
|
||||||
new_format.fill_applied = applied;
|
new_format.fill_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +464,10 @@ struct stylesheet
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.font_id = find_or_add(fonts, new_font);
|
new_format.font_id = find_or_add(fonts, new_font);
|
||||||
new_format.font_applied = applied;
|
new_format.font_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +480,10 @@ struct stylesheet
|
||||||
}
|
}
|
||||||
new_format.number_format_id = new_number_format.id();
|
new_format.number_format_id = new_number_format.id();
|
||||||
new_format.number_format_applied = applied;
|
new_format.number_format_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +492,10 @@ struct stylesheet
|
||||||
format_impl new_format = *pattern;
|
format_impl new_format = *pattern;
|
||||||
new_format.protection_id = find_or_add(protections, new_protection);
|
new_format.protection_id = find_or_add(protections, new_protection);
|
||||||
new_format.protection_applied = applied;
|
new_format.protection_applied = applied;
|
||||||
|
if (pattern->references == 0)
|
||||||
|
{
|
||||||
|
*pattern = new_format;
|
||||||
|
}
|
||||||
return find_or_create(new_format);
|
return find_or_create(new_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user