GetDunne Wiki

Notes from the desk of Shane Dunne, software development consultant

User Tools

Site Tools


eliminate_char_arrays

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
eliminate_char_arrays [2017/09/01 16:08]
shane [Use of const char* for string literals]
eliminate_char_arrays [2017/09/01 16:09] (current)
shane [Eliminating unnecessary String() constructor invocations]
Line 54: Line 54:
 along with many related definitions, for different data-types in the second argument. In every case, however, the first argument is not a //juce::String// at all, but something called a //juce::Identifier//. Presumably, the C++ compiler is accepting my //juce::String// arguments by silently invoking an appropriate //juce::Identifier// constructor I wasn't even aware of. Depending how good its optimization is, this might be quite inefficient. The lesson is clear: whenever possible, use simple string literals, and trust that the JUCE library has defined appropriate constructors to perform whatever conversions may be necessary. All the ''setAttribute'' calls in my //SynthParameters::getXml()// implementation now look like this: along with many related definitions, for different data-types in the second argument. In every case, however, the first argument is not a //juce::String// at all, but something called a //juce::Identifier//. Presumably, the C++ compiler is accepting my //juce::String// arguments by silently invoking an appropriate //juce::Identifier// constructor I wasn't even aware of. Depending how good its optimization is, this might be quite inefficient. The lesson is clear: whenever possible, use simple string literals, and trust that the JUCE library has defined appropriate constructors to perform whatever conversions may be necessary. All the ''setAttribute'' calls in my //SynthParameters::getXml()// implementation now look like this:
 <code cpp> <code cpp>
 +xml->setAttribute("masterLevel", masterLevel);
 </code> </code>
  
  
  
eliminate_char_arrays.1504282129.txt.gz ยท Last modified: 2017/09/01 16:08 by shane