|
|
|
|
|
by okmjuhb
5804 days ago
|
|
const only means that the function is not allowed to change memory through that reference. It says nothing about aliases to the same memory. But the "what if another thread changes the string" issue is a red herring. The question to keep in mind when optimizing in a multi-threaded context is "does the output of the compiler generated code correspond to at least one possible interleaving of threads". Since this thread doesn't do any synchronization, it's possible that all the function executes without being interrupted by another thread, so this is a sound optimization. |
|