Yes, if you have many subforums, this hack can be very expensive (100+ queries).
However, you can easily optimize it.
I deleted this portion:
PHP Code:
$permission=$DB_site->query_first("select accessmask from access where userid = $bbuserinfo[userid] AND forumid = $forum_child[forumid]");
if ($permission['acessmask'] != 0 || $permission['accessmask'] == null)
{
And the matching "}"
This will reduce the queries to only the number of main forums you have (mine went down from 130 to 40)
Warning To use this optimization, make sure you have no hidden/private sub-forums that reside under public forums.