Bug 778627 - Warning and related/nearby naming/style nit fixes (r=bpeterson).

This commit is contained in:
Brendan Eich 2012-07-30 13:58:18 -07:00
Родитель ce0aa8bd3f
Коммит 8b4a0accf4
3 изменённых файлов: 24 добавлений и 23 удалений

Просмотреть файл

@ -3759,7 +3759,7 @@ JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
#ifdef JS_GC_ZEAL
# define JS_SET_TRACING_LOCATION(trc, location) \
JS_BEGIN_MACRO \
if ((trc)->realLocation == NULL || (location) == NULL) \
if (!(trc)->realLocation || !(location)) \
(trc)->realLocation = (location); \
JS_END_MACRO
#else

Просмотреть файл

@ -1158,12 +1158,12 @@ ScriptSource::substring(JSContext *cx, uint32_t start, uint32_t stop)
if (compressed()) {
cached = cx->runtime->sourceDataCache.lookup(this);
if (!cached) {
const size_t memlen = sizeof(jschar) * (length_ + 1);
jschar *decompressed = static_cast<jschar *>(cx->malloc_(memlen));
const size_t nbytes = sizeof(jschar) * (length_ + 1);
jschar *decompressed = static_cast<jschar *>(cx->malloc_(nbytes));
if (!decompressed)
return NULL;
if (!DecompressString(data.compressed, compressedLength,
reinterpret_cast<unsigned char *>(decompressed), memlen)) {
if (!DecompressString(data.compressed, compressedLength_,
reinterpret_cast<unsigned char *>(decompressed), nbytes)) {
JS_ReportOutOfMemory(cx);
cx->free_(decompressed);
return NULL;
@ -1196,8 +1196,8 @@ ScriptSource::createFromSource(JSContext *cx, const jschar *src, uint32_t length
if (!ss)
return NULL;
if (!ownSource) {
const size_t memlen = length * sizeof(jschar);
ss->data.compressed = static_cast<unsigned char *>(cx->malloc_(memlen));
const size_t nbytes = length * sizeof(jschar);
ss->data.compressed = static_cast<unsigned char *>(cx->malloc_(nbytes));
if (!ss->data.compressed) {
cx->free_(ss);
return NULL;
@ -1205,7 +1205,7 @@ ScriptSource::createFromSource(JSContext *cx, const jschar *src, uint32_t length
}
ss->next = NULL;
ss->length_ = length;
ss->compressedLength = 0;
ss->compressedLength_ = 0;
ss->marked = ss->onRuntime_ = false;
ss->argumentsNotIncluded_ = argumentsNotIncluded;
#ifdef DEBUG
@ -1231,22 +1231,22 @@ void
ScriptSource::considerCompressing(JSRuntime *rt, const jschar *src, bool ownSource)
{
JS_ASSERT(!ready());
const size_t memlen = length_ * sizeof(jschar);
const size_t COMPRESS_THRESHOLD = 512;
#if USE_ZLIB
size_t compressedLen;
const size_t nbytes = length_ * sizeof(jschar);
const size_t COMPRESS_THRESHOLD = 512;
size_t compressedLength;
#endif
if (ownSource) {
data.source = const_cast<jschar *>(src);
#if USE_ZLIB
} else if (memlen >= COMPRESS_THRESHOLD && 0 &&
TryCompressString(reinterpret_cast<const unsigned char *>(src), memlen,
data.compressed, &compressedLen))
} else if (nbytes >= COMPRESS_THRESHOLD && 0 &&
TryCompressString(reinterpret_cast<const unsigned char *>(src), nbytes,
data.compressed, &compressedLength))
{
JS_ASSERT(compressedLen < memlen);
compressedLength = compressedLen;
void *mem = rt->realloc_(data.compressed, compressedLength);
JS_ASSERT(compressedLength < nbytes);
compressedLength_ = compressedLength;
void *mem = rt->realloc_(data.compressed, compressedLength_);
data.compressed = static_cast<unsigned char *>(mem);
JS_ASSERT(data.compressed);
#endif
@ -1360,14 +1360,15 @@ ScriptSource::performXDR(XDRState<mode> *xdr, ScriptSource **ssp)
}
if (!xdr->codeUint32(&ss->length_))
return false;
if (!xdr->codeUint32(&ss->compressedLength))
if (!xdr->codeUint32(&ss->compressedLength_))
return false;
uint8_t argumentsNotIncluded = ss->argumentsNotIncluded_;
if (!xdr->codeUint8(&argumentsNotIncluded))
return false;
ss->argumentsNotIncluded_ = argumentsNotIncluded;
size_t byteLen = ss->compressed() ? ss->compressedLength :
(ss->length_ * sizeof(jschar));
size_t byteLen = ss->compressed() ? ss->compressedLength_ : (ss->length_ * sizeof(jschar));
if (mode == XDR_DECODE) {
ss->data.compressed = static_cast<unsigned char *>(xdr->cx()->malloc_(byteLen));
if (!ss->data.compressed)

Просмотреть файл

@ -981,14 +981,14 @@ struct ScriptSource
ScriptSource *next;
private:
union {
// When the script source is ready, compressedLength > 0 implies
// When the script source is ready, compressedLength_ != 0 implies
// compressed holds the compressed data; otherwise, source holds the
// uncompressed source.
jschar *source;
unsigned char *compressed;
} data;
uint32_t length_;
uint32_t compressedLength;
uint32_t compressedLength_;
bool marked:1;
bool onRuntime_:1;
bool argumentsNotIncluded_:1;
@ -1023,7 +1023,7 @@ struct ScriptSource
static bool performXDR(XDRState<mode> *xdr, ScriptSource **ss);
private:
bool compressed() { return !!compressedLength; }
bool compressed() { return compressedLength_ != 0; }
void considerCompressing(JSRuntime *rt, const jschar *src, bool ownSource = false);
};