View Single Post
11/24/14, 02:07 AM   #8
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Baertram View Post
I hoped so @interesting
Thx man! I hope it is not any small bug or typo which causes this issue...
Every help is very appreciated!

Even small findings can improve the overall performance
If I understand you right:
If any of the registered filters for the current filterType (e.g. LAF_BANK) returns false the other filters shouldn't be executed/needed anymore, because the item will be hidden.
So one could abort the for ... do loop already in between?
Yes, since your always doing:
Lua Code:
  1. result = result and <something else>
if result is already false, its always going to return false, regardless of what <something else> is.


Someone please correct me if I'm misunderstanding this part, but isn't the if statement unnecessary?
Lua Code:
  1. for _,v in pairs(filters[filterType]) do
  2.    if(v) then
  3.       result = result and v(slot)
  4.    end
  5. end

Doesn't v just represent functions in the table that tell if something should be displayed or not...since v is not a boolean (correct?) then wont the: if(v) always return true. If v did not exist it never would have made it to that part of the code, it would have broken out of the for loop before that.

So then couldn't he just do:
Lua Code:
  1. for _,v in pairs(filters[filterType]) do
  2.    result = result and v(slot)
  3.    if result == false then
  4.       return result
  5.    end
  6. end

Last edited by circonian : 11/24/14 at 02:14 AM.
  Reply With Quote