tinyxml2
tinyxml2 copied to clipboard
Enhancement of PrintSpace()
Hi developers. I'd recommend to enhance XMLPrinter::PrintSpace() function. I have added ability to use TAB characters to format paddings. If we init "_spaceMode" member with value >=0 we will get the same result as in the original implementation. If we init "_spaceMode" member with value <0 will use TAB character for paddings. Using TAB character instead of default four spaces can reduce size of XML file up to 15%.
void XMLPrinter::PrintSpace( int depth )
{
char spaces[ENTITY_RANGE];
size_t size;
if (_spaceMode<0)
{
for(int i=0; i< -_spaceMode; ++i)
spaces[i] = '\t';
size = -_spaceMode;
}
else
{
for(int i=0; i<_spaceMode; ++i)
spaces[i] = ' ';
size = _spaceMode;
}
if (size!=0)
for( int i=0; i<depth; ++i )
{
Write(spaces, size);
}
}