Stuff Michael Meeks is doing |
Older items: 2023: ( J F M A M J ), 2022: ( J F M A M J J A S O N D ), 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, legacy html
"foo"
to:
struct rtl_uString { (1<<31)+1, strlen("foo"), { 'f', 'o', 'o' /* UTF-16 */ } }
Unfortunately, that appears somewhat difficult. It'd be
a great problem to crack though, making it easy to
conditionally (gcc only?) move a ton of strings into
.rodata, save a load of heap, and save doing any
ref-counting on them too).
typedef struct {
int ref;
int len;
const wchar_t buffer[4];
} Str;
#define DECL_STR(a) \
((Str *)(&((const struct { int r; int l; const wchar_t b[strlen(a) + 1]; } ) { (1<<30)+1, strlen(a), L##a })))
...
printStr(DECL_STR("Foo"));
The GCC page on
Compound Literals is quite helpful. Unfortunately gcc
(apparently) doesn't elide duplicate DECL_STR generated output
in .rodata sections (which is interesting in itself perhaps).
(sample).
My content in this blog and associated images / data under
images/
and data/
directories are (usually)
created by me and (unless obviously labelled otherwise) are licensed under
the public domain, and/or if that doesn't float your boat a CC0
license. I encourage linking back (of course) to help people decide for
themselves, in context, in the battle for ideas, and I love fixes /
improvements / corrections by private mail.
In case it's not painfully obvious: the reflections reflected here are my own; mine, all mine ! and don't reflect the views of Collabora, SUSE, Novell, The Document Foundation, Spaghetti Hurlers (International), or anyone else. It's also important to realise that I'm not in on the Swedish Conspiracy. Occasionally people ask for formal photos for conferences or fun.
Michael Meeks (michael.meeks@collabora.com)