Forum Discussion
iRule optimization : store string evaluation as boolean
Is there any advantage to storing the result of a string comparison as a boolean ?
set query_params_exist ( [HTTP::query] ne "" )
if (query_params_exist == 1) {
}
... somewhere else deep in logic
if (query_params_exist == 1) {
}
`
Or perhaps this be shortened to :
`if (query_params_exist) {
}
2 Replies
- IheartF5_45022
Nacreous
My understanding is that there is no advantage to storing the result as a variable rather than executing
if {[HTTP::query] ne ""}multiple times.
- JRahm
Admin
you will shave cycles (small, but every bit helps) by using if { $variable } instead of if { $variable == 1 }, but there is no benefit to setting a variable to a value already cached in memory like HTTP::query unless you are performing additional operations against that value multiple times, then it makes sense to set the variable.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com