mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-16 00:34:19 +00:00
A couple more optimisations of Identifier object passing.
This commit is contained in:
parent
f1c0ceccc3
commit
d8bc6c52c7
4 changed files with 15 additions and 15 deletions
|
|
@ -140,7 +140,7 @@ var* NamedValueSet::getVarPointer (const Identifier& name) const noexcept
|
|||
}
|
||||
|
||||
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
bool NamedValueSet::set (Identifier name, var&& newValue)
|
||||
bool NamedValueSet::set (const Identifier& name, var&& newValue)
|
||||
{
|
||||
if (var* const v = getVarPointer (name))
|
||||
{
|
||||
|
|
@ -156,7 +156,7 @@ bool NamedValueSet::set (Identifier name, var&& newValue)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool NamedValueSet::set (Identifier name, const var& newValue)
|
||||
bool NamedValueSet::set (const Identifier& name, const var& newValue)
|
||||
{
|
||||
if (var* const v = getVarPointer (name))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -78,14 +78,14 @@ public:
|
|||
@returns true if a value was changed or added; false if the
|
||||
value was already set the value passed-in.
|
||||
*/
|
||||
bool set (Identifier name, const var& newValue);
|
||||
bool set (const Identifier& name, const var& newValue);
|
||||
|
||||
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
/** Changes or adds a named value.
|
||||
@returns true if a value was changed or added; false if the
|
||||
value was already set the value passed-in.
|
||||
*/
|
||||
bool set (Identifier name, var&& newValue);
|
||||
bool set (const Identifier& name, var&& newValue);
|
||||
#endif
|
||||
|
||||
/** Returns true if the set contains an item with the specified name. */
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
static bool isNumericOrUndefined (const var& v) { return v.isInt() || v.isDouble() || v.isInt64() || v.isBool() || v.isUndefined(); }
|
||||
static int64 getOctalValue (const String& s) { BigInteger b; b.parseString (s, 8); return b.toInt64(); }
|
||||
static Identifier getPrototypeIdentifier() { static const Identifier i ("prototype"); return i; }
|
||||
static var* getPropertyPointer (DynamicObject* o, Identifier i) { return o->getProperties().getVarPointer (i); }
|
||||
static var* getPropertyPointer (DynamicObject* o, const Identifier& i) { return o->getProperties().getVarPointer (i); }
|
||||
|
||||
//==============================================================================
|
||||
struct CodeLocation
|
||||
|
|
@ -136,7 +136,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
ReferenceCountedObjectPtr<RootObject> root;
|
||||
DynamicObject::Ptr scope;
|
||||
|
||||
var findFunctionCall (const CodeLocation& location, const var& targetObject, Identifier functionName) const
|
||||
var findFunctionCall (const CodeLocation& location, const var& targetObject, const Identifier& functionName) const
|
||||
{
|
||||
if (DynamicObject* o = targetObject.getDynamicObject())
|
||||
{
|
||||
|
|
@ -170,7 +170,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
return var();
|
||||
}
|
||||
|
||||
var* findRootClassProperty (Identifier className, Identifier propName) const
|
||||
var* findRootClassProperty (const Identifier& className, const Identifier& propName) const
|
||||
{
|
||||
if (DynamicObject* cls = root->getProperty (className).getDynamicObject())
|
||||
return getPropertyPointer (cls, propName);
|
||||
|
|
@ -178,7 +178,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
var findSymbolInParentScopes (Identifier name) const
|
||||
var findSymbolInParentScopes (const Identifier& name) const
|
||||
{
|
||||
if (const var* v = getPropertyPointer (scope, name))
|
||||
return *v;
|
||||
|
|
@ -187,7 +187,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
: var::undefined();
|
||||
}
|
||||
|
||||
bool findAndInvokeMethod (Identifier function, const var::NativeFunctionArgs& args, var& result) const
|
||||
bool findAndInvokeMethod (const Identifier& function, const var::NativeFunctionArgs& args, var& result) const
|
||||
{
|
||||
DynamicObject* target = args.thisObject.getDynamicObject();
|
||||
|
||||
|
|
@ -352,7 +352,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
|
||||
struct UnqualifiedName : public Expression
|
||||
{
|
||||
UnqualifiedName (const CodeLocation& l, Identifier n) noexcept : Expression (l), name (n) {}
|
||||
UnqualifiedName (const CodeLocation& l, const Identifier& n) noexcept : Expression (l), name (n) {}
|
||||
|
||||
var getResult (const Scope& s) const override { return s.findSymbolInParentScopes (name); }
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
|
||||
struct DotOperator : public Expression
|
||||
{
|
||||
DotOperator (const CodeLocation& l, ExpPtr& p, Identifier c) noexcept : Expression (l), parent (p), child (c) {}
|
||||
DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p), child (c) {}
|
||||
|
||||
var getResult (const Scope& s) const override
|
||||
{
|
||||
|
|
@ -1670,7 +1670,7 @@ JavascriptEngine::~JavascriptEngine() {}
|
|||
|
||||
void JavascriptEngine::prepareTimeout() const noexcept { root->timeout = Time::getCurrentTime() + maximumExecutionTime; }
|
||||
|
||||
void JavascriptEngine::registerNativeObject (Identifier name, DynamicObject* object)
|
||||
void JavascriptEngine::registerNativeObject (const Identifier& name, DynamicObject* object)
|
||||
{
|
||||
root->setProperty (name, object);
|
||||
}
|
||||
|
|
@ -1706,7 +1706,7 @@ var JavascriptEngine::evaluate (const String& code, Result* result)
|
|||
return var::undefined();
|
||||
}
|
||||
|
||||
var JavascriptEngine::callFunction (Identifier function, const var::NativeFunctionArgs& args, Result* result)
|
||||
var JavascriptEngine::callFunction (const Identifier& function, const var::NativeFunctionArgs& args, Result* result)
|
||||
{
|
||||
var returnVal (var::undefined());
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public:
|
|||
The function arguments are passed in the same format as used by native
|
||||
methods in the var class.
|
||||
*/
|
||||
var callFunction (Identifier function,
|
||||
var callFunction (const Identifier& function,
|
||||
const var::NativeFunctionArgs& args,
|
||||
Result* errorMessage = nullptr);
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public:
|
|||
engine until the engine is deleted. The name must be a simple JS identifier,
|
||||
without any dots.
|
||||
*/
|
||||
void registerNativeObject (Identifier objectName, DynamicObject* object);
|
||||
void registerNativeObject (const Identifier& objectName, DynamicObject* object);
|
||||
|
||||
/** This value indicates how long a call to one of the evaluate methods is permitted
|
||||
to run before timing-out and failing.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue