This commit is contained in:
Robert Sayre 2009-11-30 13:55:44 -05:00
commit 1d2cb92f50

View File

@ -68,8 +68,6 @@
#include "jsstr.h"
#include "jsvector.h"
#include <algorithm>
#ifdef JS_TRACER
#include "jstracer.h"
using namespace avmplus;
@ -2077,7 +2075,9 @@ class CharSet {
public:
CharSet() : charEnd(charBuf), classes(0) {}
bool full() { return charEnd == charBuf + BufSize; }
static const uintN sBufSize = 8;
bool full() { return charEnd == charBuf + sBufSize; }
/* Add a single char to the set. */
bool addChar(jschar c)
@ -2110,8 +2110,7 @@ class CharSet {
private:
static bool disjoint(const jschar *beg, const jschar *end, uintN classes);
static const uintN BufSize = 8;
mutable jschar charBuf[BufSize];
mutable jschar charBuf[sBufSize];
jschar *charEnd;
uintN classes;
};
@ -2181,6 +2180,14 @@ set_disjoint(InputIterator1 p1, InputIterator1 end1,
return false;
}
static JSBool
CharCmp(void *arg, const void *a, const void *b, int *result)
{
jschar ca = *(jschar *)a, cb = *(jschar *)b;
*result = ca - cb;
return JS_TRUE;
}
bool
CharSet::disjoint(const CharSet &other) const
{
@ -2197,8 +2204,11 @@ CharSet::disjoint(const CharSet &other) const
return false;
/* Check char-char overlap. */
std::sort(charBuf, charEnd);
std::sort(other.charBuf, other.charEnd);
jschar tmp[CharSet::sBufSize];
js_MergeSort(charBuf, charEnd - charBuf, sizeof(jschar),
CharCmp, 0, tmp);
js_MergeSort(other.charBuf, other.charEnd - other.charBuf, sizeof(jschar),
CharCmp, 0, tmp);
return set_disjoint(charBuf, charEnd, other.charBuf, other.charEnd);
}