Monday
Jul182005
NDD: Niggly Detail Of The Day
Monday, July 18, 2005 at 3:56PM
The code I've come to own is literally covered in crap like this. This one drove me crazy...
That snippet was converted to user my new search code last week, and today I was having some odd display errors with my search results. The results were fine, but the 'help' text was showing up.
Turns out, that in the above statement, the '1' argument to
UPDATE: Kevin pointed out that the original logic is broken, because if there WERE results, it would break the AND, resulting in a call to search_help(). This was the bug that got me here in the first place, and I fixed it by making the described changes. That is all.
if ( $s->count() == 0 and $s->type() =~ /title/i) {
$self->search_help(1);
} else {
$self->search_help;
}
That snippet was converted to user my new search code last week, and today I was having some odd display errors with my search results. The results were fine, but the 'help' text was showing up.
Turns out, that in the above statement, the '1' argument to
search_help, if present, causes it to immediately return. Effectively making it a null op with the overhead of a function call. This was reduced to:
if ( $s->count() == 0 and $s->type() !~ /title/i) {
$self->search_help;
}
UPDATE: Kevin pointed out that the original logic is broken, because if there WERE results, it would break the AND, resulting in a call to search_help(). This was the bug that got me here in the first place, and I fixed it by making the described changes. That is all.
in
General
General 
Reader Comments