author | Georg Fritzsche <georg.fritzsche@googlemail.com> |
Wed, 20 Jul 2016 17:10:24 +0200 | |
changeset 306069 | 58344005efca56b77c38459955f4099ad9f68f22 |
parent 306068 | 6a5f0538b3c907f9a9f5a4851aaae2494e08b165 |
child 306070 | 45b83bf04a2617969b8b5664f7dc3f11e118815f |
push id | 79765 |
push user | cbook@mozilla.com |
push date | Thu, 21 Jul 2016 14:26:34 +0000 |
treeherder | mozilla-inbound@ab54bfc55266 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | froydnj |
bugs | 1188888 |
milestone | 50.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
toolkit/components/telemetry/shared_telemetry_utils.py | file | annotate | diff | comparison | revisions |
--- a/toolkit/components/telemetry/shared_telemetry_utils.py +++ b/toolkit/components/telemetry/shared_telemetry_utils.py @@ -32,40 +32,50 @@ class StringTable: else: result = self.current_index self.table[string] = result self.current_index += self.c_strlen(string) return result def writeDefinition(self, f, name): """Writes the string table to a file as a C const char array. + + This writes out the string table as one single C char array for memory + size reasons, separating the individual strings with '\0' characters. + This way we can index directly into the string array and avoid the additional + storage costs for the pointers to them (and potential extra relocations for those). + :param f: the output stream. :param name: the name of the output array. """ entries = self.table.items() entries.sort(key=lambda x:x[1]) + # Avoid null-in-string warnings with GCC and potentially # overlong string constants; write everything out the long way. def explodeToCharArray(string): def toCChar(s): if s == "'": return "'\\''" else: return "'%s'" % s return ", ".join(map(toCChar, string)) + f.write("const char %s[] = {\n" % name) - for (string, offset) in entries[:-1]: + for (string, offset) in entries: + if "*/" in string: + raise ValueError, "String in string table contains unexpected sequence '*/': %s" % string + e = explodeToCharArray(string) if e: - f.write(" /* %5d */ %s, '\\0',\n" - % (offset, explodeToCharArray(string))) + f.write(" /* %5d - \"%s\" */ %s, '\\0',\n" + % (offset, string, explodeToCharArray(string))) else: - f.write(" /* %5d */ '\\0',\n" % offset) - f.write(" /* %5d */ %s, '\\0' };\n\n" - % (entries[-1][1], explodeToCharArray(entries[-1][0]))) + f.write(" /* %5d - \"%s\" */ '\\0',\n" % (offset, string)) + f.write("};\n\n") def static_assert(output, expression, message): """Writes a C++ compile-time assertion expression to a file. :param output: the output stream. :param expression: the expression to check. :param message: the string literal that will appear if the expression evaluates to false. """