Bug 1303328 - Avoid constructing strings to feed to InferSpew if inactive, r=jandem

--HG--
extra : rebase_source : a54f6c6163b411bf41df4bb86b81259d137ee62d
This commit is contained in:
Steve Fink 2016-10-04 11:31:31 -07:00
parent 52a7c7eaf5
commit 02ddcda415
2 changed files with 10 additions and 7 deletions

View File

@ -152,7 +152,8 @@ TypeSet::ObjectGroupString(ObjectGroup* group)
#ifdef DEBUG
static bool InferSpewActive(SpewChannel channel)
bool
js::InferSpewActive(SpewChannel channel)
{
static bool active[SPEW_COUNT];
static bool checked = false;
@ -222,12 +223,10 @@ js::InferSpewColor(TypeSet* types)
return colors[DefaultHasher<TypeSet*>::hash(types) % 7];
}
#ifdef DEBUG
void
js::InferSpew(SpewChannel channel, const char* fmt, ...)
js::InferSpewImpl(const char* fmt, ...)
{
if (!InferSpewActive(channel))
return;
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "[infer] ");
@ -235,6 +234,7 @@ js::InferSpew(SpewChannel channel, const char* fmt, ...)
fprintf(stderr, "\n");
va_end(ap);
}
#endif
MOZ_NORETURN MOZ_COLD static void
TypeFailure(JSContext* cx, const char* fmt, ...)

View File

@ -1290,11 +1290,13 @@ enum SpewChannel {
#ifdef DEBUG
bool InferSpewActive(SpewChannel channel);
const char * InferSpewColorReset();
const char * InferSpewColor(TypeConstraint* constraint);
const char * InferSpewColor(TypeSet* types);
void InferSpew(SpewChannel which, const char* fmt, ...);
#define InferSpew(channel, ...) if (InferSpewActive(channel)) { InferSpewImpl(__VA_ARGS__); } else {}
void InferSpewImpl(const char* fmt, ...);
/* Check that the type property for id in group contains value. */
bool ObjectGroupHasProperty(JSContext* cx, ObjectGroup* group, jsid id, const Value& value);
@ -1304,7 +1306,8 @@ bool ObjectGroupHasProperty(JSContext* cx, ObjectGroup* group, jsid id, const Va
inline const char * InferSpewColorReset() { return nullptr; }
inline const char * InferSpewColor(TypeConstraint* constraint) { return nullptr; }
inline const char * InferSpewColor(TypeSet* types) { return nullptr; }
inline void InferSpew(SpewChannel which, const char* fmt, ...) {}
#define InferSpew(channel, ...) do {} while (0)
#endif