common array: ++enhance the usability.

add last() which indicates the last element pointer.
This commit is contained in:
Hermet Park 2023-06-23 16:39:13 +09:00 committed by Hermet Park
parent 3fa33c0315
commit bd87f1398c
2 changed files with 6 additions and 1 deletions

View file

@ -73,6 +73,11 @@ struct Array
return data + count; return data + count;
} }
T* last()
{
return data + count - 1;
}
void pop() void pop()
{ {
if (count > 0) --count; if (count > 0) --count;

View file

@ -674,7 +674,7 @@ TvgBinCounter TvgSaver::serializeChildren(Iterator* it, const Matrix* pTransform
while (auto child = it->next()) { while (auto child = it->next()) {
if (child->identifier() == TVG_CLASS_ID_SHAPE) { if (child->identifier() == TVG_CLASS_ID_SHAPE) {
//only dosable if the previous child is a shape. //only dosable if the previous child is a shape.
auto target = children.ptr() - 1; auto target = children.last();
if ((*target)->identifier() == TVG_CLASS_ID_SHAPE) { if ((*target)->identifier() == TVG_CLASS_ID_SHAPE) {
if (_merge((Shape*)child, (Shape*)*target)) { if (_merge((Shape*)child, (Shape*)*target)) {
continue; continue;