mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-23 01:44:22 +00:00
Minor string optimisation.
This commit is contained in:
parent
0ce65462af
commit
cf959decce
3 changed files with 14 additions and 3 deletions
|
|
@ -65,7 +65,7 @@ inline int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept { r
|
|||
nullptr if the pointer is null.
|
||||
*/
|
||||
template <class Type>
|
||||
inline Type* createCopyIfNotNull (Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; }
|
||||
inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; }
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_MAC || JUCE_IOS || DOXYGEN
|
||||
|
|
|
|||
|
|
@ -128,6 +128,18 @@ public:
|
|||
return dest;
|
||||
}
|
||||
|
||||
static CharPointerType createFromCharPointer (const CharPointerType& start, const CharPointerType& end)
|
||||
{
|
||||
if (start.getAddress() == nullptr || start.isEmpty())
|
||||
return getEmpty();
|
||||
|
||||
const size_t numBytes = end.getAddress() - start.getAddress();
|
||||
const CharPointerType dest (createUninitialisedBytes (numBytes + 1));
|
||||
memcpy (dest.getAddress(), start, numBytes);
|
||||
dest.getAddress()[numBytes] = 0;
|
||||
return dest;
|
||||
}
|
||||
|
||||
static CharPointerType createFromFixedLength (const char* const src, const size_t numChars)
|
||||
{
|
||||
const CharPointerType dest (createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType)));
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ public:
|
|||
menuBarItemsChanged (nullptr);
|
||||
}
|
||||
|
||||
extraAppleMenuItems = newExtraAppleMenuItems != nullptr ? new PopupMenu (*newExtraAppleMenuItems)
|
||||
: nullptr;
|
||||
extraAppleMenuItems = createCopyIfNotNull (newExtraAppleMenuItems);
|
||||
}
|
||||
|
||||
void addSubMenu (NSMenu* parent, const PopupMenu& child,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue