Hey, in uc_restrict_qty.module, there is one major inefficient loop. Looking at the uc_restrict_qty_form_alter() function, the following exists:

...
for ($i = 0, $j = count(uc_cart_get_contents()); $i < $j; $i++) {
...
}

The uc_cart_get_contents() function will be executed every time that loop occurs, and is very inefficient. It should probably be changed to:

...
$total = count(uc_cart_get_contents());
for ($i = 0, $j = $total; $i < $j; $i++) {
...
}

A patch is attached to make it a little easier :)

CommentFileSizeAuthor
uc_restrict_qty.patch673 bytesmbelos

Comments

rszrama’s picture

Status: Active » Closed (works as designed)

Actually, notice that I'm instantiating $j in the first parameter of that for loop. Those instructions are only executed once, meaning that at the start of the loop $i will be set to 0 and $j to the number of items in the cart. After that, the second parameter will perform the evaluation of $i < $j. The code is optimal as is. : )

mbelos’s picture

Ah I see now, was a bit too quick on the trigger there! My apologies :)