GNOME Bugzilla – Bug 571088
substantialy shrink XML files ...
Last modified: 2009-02-15 07:06:00 UTC
The patch essentially replaces 8 space characters with tabs, and micro-optimises the writing code to avoid dynamic allocation of indent strings when writing. This saves me around half of my main schema / defaults xml file - and speeds up parsing it too by a fair whack, and loading the result in emacs, you'd never know :-)
Created attachment 128330 [details] [review] use tabs not spaces lamer than I remember we should prolly s/INDENT_SPACES/INDENT_TABS/ if we even need such a #define anymore.
Any reason you don't just have one string static const char *tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; and just return tabs + sizeof (tabs) - 1 - indent; (i.e. pull as many tabs as you need from the back of the string) ? As far as the corner case goes where there is more than a reasonable amount of indentation, maybe it makes sense to just stop indenting? if the point of indenting is for readability, then there's no point indenting after the text has wrapped in the users editor, because they're just going to get weird stair stepping anyway. I guess it'd just be return MAX (tabs, tabs + sizeof (tabs) - 1 - indent); then. I like the idea of shrinking the XML files.
Oh - the answer is because I'm a dofus ;-) was just thinking about how idiotic that was as I dropped off the kids - senility comes easily to those used to a world of C++ string wrapper classes. And yes - binning the tested-but-unpleasant alloca case would be great. How are we for maintainers these days ? - may I commit with the above tweak ?
no maintainers as far as i know. Sometimes chpe, or vuntz, or me, or others do a run through bugzilla. I'd just commit it if i were you.
oh - good show :-) committed to HEAD; will commit some other trivial XML optimizations directly; but paste the more interesting / controversial / higher win one in a bug sometime soon.
Thanks Michael. Looks hilariously ridiculous!
Lets close this then, I guess.