mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 780051 - Remove JS_MAX and JS_MIN. r=luke
This commit is contained in:
parent
f9b3ec6209
commit
1c1e824772
@ -444,7 +444,7 @@ jsd_AppendUCSourceText(JSDContext* jsdc,
|
||||
}
|
||||
}
|
||||
while(remaining && jsdsrc) {
|
||||
int bytes = JS_MIN(remaining, UNICODE_TRUNCATE_BUF_SIZE);
|
||||
int bytes = (remaining < UNICODE_TRUNCATE_BUF_SIZE) ? remaining : UNICODE_TRUNCATE_BUF_SIZE;
|
||||
int i;
|
||||
for(i = 0; i < bytes; i++)
|
||||
buf[i] = (const char) *(text++);
|
||||
|
@ -6715,7 +6715,7 @@ frontend::NewSrcNote(JSContext *cx, BytecodeEmitter *bce, SrcNoteType type)
|
||||
bce->current->lastNoteOffset = offset;
|
||||
if (delta >= SN_DELTA_LIMIT) {
|
||||
do {
|
||||
xdelta = JS_MIN(delta, SN_XDELTA_MASK);
|
||||
xdelta = Min(delta, SN_XDELTA_MASK);
|
||||
SN_MAKE_XDELTA(sn, xdelta);
|
||||
delta -= xdelta;
|
||||
index = AllocSrcNote(cx, bce);
|
||||
@ -6948,7 +6948,7 @@ frontend::FinishTakingSrcNotes(JSContext *cx, BytecodeEmitter *bce, jssrcnote *n
|
||||
offset -= delta;
|
||||
if (offset == 0)
|
||||
break;
|
||||
delta = JS_MIN(offset, SN_XDELTA_MASK);
|
||||
delta = Min(offset, SN_XDELTA_MASK);
|
||||
sn = bce->main.notes;
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ MapAlignedPages(size_t size, size_t alignment)
|
||||
}
|
||||
|
||||
/* Overallocate and unmap the region's edges. */
|
||||
size_t reqSize = JS_MIN(size + 2 * alignment, 2 * size);
|
||||
size_t reqSize = Min(size + 2 * alignment, 2 * size);
|
||||
void *region = mmap(NULL, reqSize, prot, flags, -1, 0);
|
||||
if (region == MAP_FAILED)
|
||||
return NULL;
|
||||
|
@ -2111,7 +2111,7 @@ AddNameToArray(JSContext *cx, PropertyName *name, JSIdArray *ida, int *ip)
|
||||
int i = *ip;
|
||||
int length = ida->length;
|
||||
if (i >= length) {
|
||||
ida = SetIdArrayLength(cx, ida, JS_MAX(length * 2, 8));
|
||||
ida = SetIdArrayLength(cx, ida, Max(length * 2, 8));
|
||||
if (!ida)
|
||||
return NULL;
|
||||
JS_ASSERT(i < ida->length);
|
||||
|
@ -2653,9 +2653,9 @@ array_splice(JSContext *cx, unsigned argc, Value *vp)
|
||||
/* Step 6. */
|
||||
uint32_t actualStart;
|
||||
if (relativeStart < 0)
|
||||
actualStart = JS_MAX(len + relativeStart, 0);
|
||||
actualStart = Max(len + relativeStart, 0.0);
|
||||
else
|
||||
actualStart = JS_MIN(relativeStart, len);
|
||||
actualStart = Min(relativeStart, double(len));
|
||||
|
||||
/* Step 7. */
|
||||
uint32_t actualDeleteCount;
|
||||
@ -2663,7 +2663,7 @@ array_splice(JSContext *cx, unsigned argc, Value *vp)
|
||||
double deleteCountDouble;
|
||||
if (!ToInteger(cx, argc >= 2 ? args[1] : Int32Value(0), &deleteCountDouble))
|
||||
return false;
|
||||
actualDeleteCount = JS_MIN(JS_MAX(deleteCountDouble, 0), len - actualStart);
|
||||
actualDeleteCount = Min(Max(deleteCountDouble, 0.0), double(len - actualStart));
|
||||
} else {
|
||||
/*
|
||||
* Non-standard: if start was specified but deleteCount was omitted,
|
||||
|
@ -379,7 +379,7 @@ JSStructuredCloneWriter::checkStack()
|
||||
/* To avoid making serialization O(n^2), limit stack-checking at 10. */
|
||||
const size_t MAX = 10;
|
||||
|
||||
size_t limit = JS_MIN(counts.length(), MAX);
|
||||
size_t limit = Min(counts.length(), MAX);
|
||||
JS_ASSERT(objs.length() == counts.length());
|
||||
size_t total = 0;
|
||||
for (size_t i = 0; i < limit; i++) {
|
||||
|
@ -738,7 +738,7 @@ ndigits(size_t n, size_t *result, const jschar *s, size_t* i, size_t limit)
|
||||
{
|
||||
size_t init = *i;
|
||||
|
||||
if (digits(result, s, i, JS_MIN(limit, init+n)))
|
||||
if (digits(result, s, i, Min(limit, init+n)))
|
||||
return ((*i - init) == n);
|
||||
|
||||
*i = init;
|
||||
|
@ -275,7 +275,7 @@ JS_DHashTableSetAlphaBounds(JSDHashTable *table,
|
||||
JS_ASSERT(JS_DHASH_MIN_SIZE - (maxAlpha * JS_DHASH_MIN_SIZE) >= 1);
|
||||
if (JS_DHASH_MIN_SIZE - (maxAlpha * JS_DHASH_MIN_SIZE) < 1) {
|
||||
maxAlpha = (float)
|
||||
(JS_DHASH_MIN_SIZE - JS_MAX(JS_DHASH_MIN_SIZE / 256, 1))
|
||||
(JS_DHASH_MIN_SIZE - Max(JS_DHASH_MIN_SIZE / 256, 1))
|
||||
/ JS_DHASH_MIN_SIZE;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ JS_DHashTableSetAlphaBounds(JSDHashTable *table,
|
||||
JS_ASSERT(minAlpha < maxAlpha / 2);
|
||||
if (minAlpha >= maxAlpha / 2) {
|
||||
size = JS_DHASH_TABLE_SIZE(table);
|
||||
minAlpha = (size * maxAlpha - JS_MAX(size / 256, 1)) / (2 * size);
|
||||
minAlpha = (size * maxAlpha - Max(size / 256, 1U)) / (2 * size);
|
||||
}
|
||||
|
||||
table->maxAlphaFrac = (uint8_t)(maxAlpha * 256);
|
||||
|
@ -2707,7 +2707,7 @@ END_VARLEN_CASE
|
||||
|
||||
BEGIN_CASE(JSOP_ACTUALSFILLED)
|
||||
{
|
||||
PUSH_INT32(JS_MAX(regs.fp()->numActualArgs(), GET_UINT16(regs.pc)));
|
||||
PUSH_INT32(Max(regs.fp()->numActualArgs(), GET_UINT16(regs.pc)));
|
||||
}
|
||||
END_CASE(JSOP_ACTUALSFILLED)
|
||||
|
||||
|
@ -3617,7 +3617,7 @@ JSObject::growElements(JSContext *cx, unsigned newcap)
|
||||
? oldcap * 2
|
||||
: oldcap + (oldcap >> 3);
|
||||
|
||||
uint32_t actualCapacity = JS_MAX(newcap, nextsize);
|
||||
uint32_t actualCapacity = Max(newcap, nextsize);
|
||||
if (actualCapacity >= CAPACITY_CHUNK)
|
||||
actualCapacity = JS_ROUNDUP(actualCapacity, CAPACITY_CHUNK);
|
||||
else if (actualCapacity < SLOT_CAPACITY_MIN)
|
||||
|
@ -629,7 +629,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
|
||||
uint32_t len;
|
||||
JS_ALWAYS_TRUE(js_GetLengthProperty(cx, replacer, &len));
|
||||
if (replacer->isDenseArray())
|
||||
len = JS_MIN(len, replacer->getDenseArrayCapacity());
|
||||
len = Min(len, replacer->getDenseArrayCapacity());
|
||||
|
||||
HashSet<jsid> idSet(cx);
|
||||
if (!idSet.init(len))
|
||||
@ -702,7 +702,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
|
||||
/* Step 6. */
|
||||
double d;
|
||||
JS_ALWAYS_TRUE(ToInteger(cx, space, &d));
|
||||
d = JS_MIN(10, d);
|
||||
d = Min(10.0, d);
|
||||
if (d >= 1 && !gap.appendN(' ', uint32_t(d)))
|
||||
return false;
|
||||
} else if (space.isString()) {
|
||||
@ -711,7 +711,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
|
||||
if (!str)
|
||||
return false;
|
||||
JS::Anchor<JSString *> anchor(str);
|
||||
size_t len = JS_MIN(10, space.toString()->length());
|
||||
size_t len = Min(size_t(10), space.toString()->length());
|
||||
if (!gap.append(str->chars(), len))
|
||||
return false;
|
||||
} else {
|
||||
|
@ -110,7 +110,7 @@ SkipSpace(const jschar *s, const jschar *end)
|
||||
inline bool
|
||||
CompareChars(const jschar *s1, size_t l1, const jschar *s2, size_t l2, int32_t *result)
|
||||
{
|
||||
size_t n = JS_MIN(l1, l2);
|
||||
size_t n = Min(l1, l2);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (int32_t cmp = s1[i] - s2[i]) {
|
||||
*result = cmp;
|
||||
|
@ -147,8 +147,6 @@
|
||||
***********************************************************************/
|
||||
#define JS_HOWMANY(x,y) (((x)+(y)-1)/(y))
|
||||
#define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y))
|
||||
#define JS_MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#define JS_MAX(x,y) ((x)>(y)?(x):(y))
|
||||
|
||||
#include "jscpucfg.h"
|
||||
|
||||
|
@ -177,7 +177,7 @@ ValToBin(unsigned logscale, uint32_t val)
|
||||
: (logscale == 2)
|
||||
? (unsigned) JS_CEILING_LOG2W(val)
|
||||
: val;
|
||||
return JS_MIN(bin, 10);
|
||||
return Min(bin, 10U);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -74,8 +74,8 @@ VerifyRange(void *start1, size_t size1, void *start2, size_t size2)
|
||||
uintptr_t end1 = uintptr_t(start1) + size1;
|
||||
uintptr_t end2 = uintptr_t(start2) + size2;
|
||||
|
||||
uintptr_t lowest = JS_MIN(uintptr_t(start1), uintptr_t(start2));
|
||||
uintptr_t highest = JS_MAX(end1, end2);
|
||||
uintptr_t lowest = Min(uintptr_t(start1), uintptr_t(start2));
|
||||
uintptr_t highest = Max(end1, end2);
|
||||
|
||||
return (highest - lowest < INT_MAX);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ PRMJ_Now(void)
|
||||
|
||||
/* On some dual processor/core systems, we might get an earlier time
|
||||
so we cache the last time that we returned */
|
||||
calibration.last = JS_MAX(calibration.last, int64_t(highresTime));
|
||||
calibration.last = js::Max(calibration.last, int64_t(highresTime));
|
||||
returnedTime = calibration.last;
|
||||
MUTEX_UNLOCK(&calibration.data_lock);
|
||||
|
||||
@ -692,7 +692,7 @@ DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContex
|
||||
oldRangeEndSeconds = rangeEndSeconds;
|
||||
|
||||
if (rangeStartSeconds <= localTimeSeconds) {
|
||||
int64_t newEndSeconds = JS_MIN(rangeEndSeconds + RANGE_EXPANSION_AMOUNT, MAX_UNIX_TIMET);
|
||||
int64_t newEndSeconds = js::Min(rangeEndSeconds + RANGE_EXPANSION_AMOUNT, MAX_UNIX_TIMET);
|
||||
if (newEndSeconds >= localTimeSeconds) {
|
||||
int64_t endOffsetMilliseconds = computeDSTOffsetMilliseconds(newEndSeconds);
|
||||
if (endOffsetMilliseconds == offsetMilliseconds) {
|
||||
@ -715,7 +715,7 @@ DSTOffsetCache::getDSTOffsetMilliseconds(int64_t localTimeMilliseconds, JSContex
|
||||
return offsetMilliseconds;
|
||||
}
|
||||
|
||||
int64_t newStartSeconds = JS_MAX(rangeStartSeconds - RANGE_EXPANSION_AMOUNT, 0);
|
||||
int64_t newStartSeconds = js::Max(rangeStartSeconds - RANGE_EXPANSION_AMOUNT, int64_t(0));
|
||||
if (newStartSeconds <= localTimeSeconds) {
|
||||
int64_t startOffsetMilliseconds = computeDSTOffsetMilliseconds(newStartSeconds);
|
||||
if (startOffsetMilliseconds == offsetMilliseconds) {
|
||||
|
@ -178,7 +178,7 @@ OptionParser::printHelp(const char *progname)
|
||||
size_t fmtChars = sizeof(fmt) - 2;
|
||||
size_t lhsLen = 0;
|
||||
for (Option **it = arguments.begin(), **end = arguments.end(); it != end; ++it)
|
||||
lhsLen = JS_MAX(lhsLen, strlen((*it)->longflag) + fmtChars);
|
||||
lhsLen = Max(lhsLen, strlen((*it)->longflag) + fmtChars);
|
||||
|
||||
for (Option **it = arguments.begin(), **end = arguments.end(); it != end; ++it) {
|
||||
Option *arg = *it;
|
||||
@ -206,7 +206,7 @@ OptionParser::printHelp(const char *progname)
|
||||
size_t len = fmtLen + longflagLen;
|
||||
if (opt->isValued())
|
||||
len += strlen(opt->asValued()->metavar);
|
||||
lhsLen = JS_MAX(lhsLen, len);
|
||||
lhsLen = Max(lhsLen, len);
|
||||
}
|
||||
|
||||
/* Print option help text. */
|
||||
|
@ -4102,13 +4102,13 @@ ApplyOrCall(JSContext *cx, unsigned argc, Value *vp, ApplyOrCallMode mode)
|
||||
RootedObject argsobj(cx, &args[1].toObject());
|
||||
if (!js_GetLengthProperty(cx, argsobj, &callArgc))
|
||||
return false;
|
||||
callArgc = unsigned(JS_MIN(callArgc, StackSpace::ARGS_LENGTH_MAX));
|
||||
callArgc = unsigned(Min(callArgc, StackSpace::ARGS_LENGTH_MAX));
|
||||
if (!argv.growBy(callArgc) || !GetElements(cx, argsobj, callArgc, argv.begin()))
|
||||
return false;
|
||||
callArgv = argv.begin();
|
||||
}
|
||||
} else {
|
||||
callArgc = argc > 0 ? unsigned(JS_MIN(argc - 1, StackSpace::ARGS_LENGTH_MAX)) : 0;
|
||||
callArgc = argc > 0 ? unsigned(Min(argc - 1, StackSpace::ARGS_LENGTH_MAX)) : 0;
|
||||
callArgv = args.array() + 1;
|
||||
}
|
||||
for (unsigned i = 0; i < callArgc; i++) {
|
||||
|
@ -277,14 +277,14 @@ template<typename T>
|
||||
inline T
|
||||
min(T t1, T t2)
|
||||
{
|
||||
return JS_MIN(t1, t2);
|
||||
return js::Min(t1, t2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T
|
||||
max(T t1, T t2)
|
||||
{
|
||||
return JS_MAX(t1, t2);
|
||||
return js::Max(t1, t2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -482,7 +482,7 @@ inline JSBool
|
||||
XPCNativeSet::MatchesSetUpToInterface(const XPCNativeSet* other,
|
||||
XPCNativeInterface* iface) const
|
||||
{
|
||||
int count = JS_MIN((int)mInterfaceCount, (int)other->mInterfaceCount);
|
||||
int count = js::Min(int(mInterfaceCount), int(other->mInterfaceCount));
|
||||
|
||||
XPCNativeInterface* const * pp1 = mInterfaces;
|
||||
XPCNativeInterface* const * pp2 = other->mInterfaces;
|
||||
|
Loading…
Reference in New Issue
Block a user