Forum Discussion
Kai_Wilke
Dec 14, 2016MVP
Hi BaltoStar,
if the given variable exists in 90% of the cases, then
[catch {}]
will do an awesome job...
when HTTP_REQUEST {
if { [catch {
if { $variable } then {
log local0.debug "The variable does exist and has a value of 1"
}
}] } then {
log local0.debug "The variable does not exists."
}
}
... but if the variable exists in less than 90% of the cases, then
[info exists]
will start to outperform [catch {}]
.
when HTTP_REQUEST {
if { ( [info exists variable] )
and ( $variable ) } then {
log local0.debug "the variable does exist and has a value of 1"
} else {
log local0.debug "The variable does not exists or has an value other than 1."
}
}
Note: The reson for this is that a successful
command is slightly faster than [catch {}]
but on the other hand an unsuccessful [info exists]
command is much slower than [catch {}]
.[info exists]
Cheers, Kai