[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.1/kdelibs/kjs
From: Maks Orlovich <maksim () kde ! org>
Date: 2008-10-29 3:52:31
Message-ID: 1225252351.451361.8776.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 877278 by orlovich:
Fix the immediate-value path of getNumber nor enforcing, uhm, Numberness.
Fixes optimized versions of some comparisons confusing things like
null with numbers.
BUG:173202
M +21 -0 JSImmediate.h
M +2 -3 value.h
--- branches/KDE/4.1/kdelibs/kjs/JSImmediate.h #877277:877278
@@ -118,6 +118,11 @@
}
static double toDouble(const JSValue*);
+
+ // Non-converting getters for Number's
+ static double getNumber(const JSValue*); // This returns NaN if the value is not a Number.
+ static bool getNumber(const JSValue*, double& valOut);
+
static bool toBoolean(const JSValue*);
static JSObject* toObject(const JSValue*, ExecState*);
static UString toString(const JSValue*);
@@ -266,6 +271,22 @@
return i;
}
+ALWAYS_INLINE double JSImmediate::getNumber(const JSValue* v)
+{
+ ASSERT(isImmediate(v));
+ const int32_t i = static_cast<int32_t>(unTag(v)) >> 2;
+ if (JSImmediate::getTag(v) != NumberType)
+ return NaN;
+ return i;
+}
+
+ALWAYS_INLINE bool JSImmediate::getNumber(const JSValue* v, double& numberOut)
+{
+ ASSERT(isImmediate(v));
+ numberOut = static_cast<int32_t>(unTag(v)) >> 2;
+ return (JSImmediate::getTag(v) == NumberType);
+}
+
ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i)
{
const int32_t si = static_cast<int32_t>(unTag(v)) >> 2;
--- branches/KDE/4.1/kdelibs/kjs/value.h #877277:877278
@@ -379,15 +379,14 @@
inline bool JSValue::getNumber(double& v) const
{
if (JSImmediate::isImmediate(this)) {
- v = JSImmediate::toDouble(this);
- return true;
+ return JSImmediate::getNumber(this, v);
}
return asCell()->getNumber(v);
}
inline double JSValue::getNumber() const
{
- return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber();
+ return JSImmediate::isImmediate(this) ? JSImmediate::getNumber(this) : asCell()->getNumber();
}
inline bool JSValue::getString(UString& s) const
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic