The surprisingly high cost of static-lifetime constructors--Arthur O’Dwyer

Save to:
Instapaper Pocket Readability

Today we look at compile time performance.

The surprisingly high cost of static-lifetime constructors

by Arthur O’Dwyer

From the article:

I was looking at HyperRogue again this week (see my previous post). It has a really nice localization framework: every message in the game can be translated just by adding a lookup entry to a single file (like, for the Czech translation, you add entries to language-cz.cpp); and then during the build process, all the language-??.cpp files are collated together and used to produce a single language-data.cpp file with a lookup table from each English message to the same message in every other language. (Seeing all the messages at once allows us to report on how “complete” each translation is, relative to the others.)...

 

Add a Comment

Comments are closed.

Comments (1)

0 0

ivafanas said on Jun 27, 2018 09:44 PM:

I don't see any threadsafe guards there
https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c++,source:'
#include+<map>

void+foo()
{
++++std::map<std::string,+std::string>+m+={{"a",+"b"},+{"c",+"d"}};


}'),l:'5',n:'0',o:'C+++source+#1',t:'0')),k:42.5065274151436,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang600,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',trim:'0'),lang:c++,libs:!(),options:'-O3',source:1),l:'5',n:'0',o:'x86-64+clang+6.0.0+(Editor+#1,+Compiler+#1)+C++',t:'0')),k:57.4934725848564,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4

If you add a static std::string to the function code threadsafe guards will appear.
Looks like a misunderstanding.