Bug 759626 - Cache the result of InferSpewColorable to avoid a ton of getenv calls. r=bhackett

--HG--
extra : rebase_source : bcf1055b9f401561c1bbc33a4757177df1b81d60
This commit is contained in:
Jan de Mooij 2012-05-30 20:24:04 +02:00
parent 3b11140cbd
commit ee3c9c779a

View File

@ -138,10 +138,17 @@ static bool InferSpewActive(SpewChannel channel)
static bool InferSpewColorable()
{
/* Only spew colors on xterm-color to not screw up emacs. */
const char *env = getenv("TERM");
if (!env)
return false;
return strcmp(env, "xterm-color") == 0;
static bool colorable = false;
static bool checked = false;
if (!checked) {
checked = true;
const char *env = getenv("TERM");
if (!env)
return false;
if (strcmp(env, "xterm-color") == 0 || strcmp(env, "xterm-256color") == 0)
colorable = true;
}
return colorable;
}
const char *