After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 571088 - substantialy shrink XML files ...
substantialy shrink XML files ...
Status: RESOLVED FIXED
Product: GConf
Classification: Deprecated
Component: Markup backend
CVS HEAD
Other Linux
: Normal major
: ---
Assigned To: GConf Maintainers
GConf Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-02-09 20:46 UTC by Michael Meeks
Modified: 2009-02-15 07:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
use tabs not spaces (5.95 KB, patch)
2009-02-09 20:48 UTC, Michael Meeks
none Details | Review

Description Michael Meeks 2009-02-09 20:46:37 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 :-)
Comment 1 Michael Meeks 2009-02-09 20:48:10 UTC
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.
Comment 2 Ray Strode [halfline] 2009-02-09 21:11:49 UTC
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.
Comment 3 Michael Meeks 2009-02-10 11:02:31 UTC
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 ?
Comment 4 Ray Strode [halfline] 2009-02-10 14:25:22 UTC
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. 
Comment 5 Michael Meeks 2009-02-10 17:05:25 UTC
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.
Comment 6 Behdad Esfahbod 2009-02-11 05:22:18 UTC
Thanks Michael.  Looks hilariously ridiculous!
Comment 7 Matthias Clasen 2009-02-15 07:06:00 UTC
Lets close this then, I guess.