Forum Discussion

Chris_Miller's avatar
Chris_Miller
Icon for Altostratus rankAltostratus
Aug 20, 2010

Most efficient way to log?


HTTP::cookie insert name "test" value [class search -value test eq [IP::server_addr]] path /
        log local0. "inserting cookie for test [class search -value test eq [IP::server_addr]] since server was [IP::server_addr]"
or

set test [class search -value test eq [IP::server_addr]]
HTTP::cookie insert name "test" value $test path /
        log local0. "inserting cookie for test $test since server was [IP::server_addr]"
I know I can use "timing" to find out but am curious whether there's hard and fast rules as to when it's useful to set a variable vs doing multiple data group comparisons, etc.

2 Replies

  • Chris: I think avoiding the variable is the way to go. The obvious downside is readability, obviously.

     

     

    -Matt
  • In this instance Chris, the variable is almost certainy the way to go, particularly as your class sizes grow. This is why testing is so important. Sometimes the use of variable IS the optimized approach, though often it is not.