X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Code Bloat? (https://forum.x-cart.com/showthread.php?t=24982)

carpeperdiem 09-16-2006 06:06 AM

Code Bloat?
 
Dear Brain-Trust:

As I get closer to going live (I could press the button now if I wanted to) I have some minor concerns re: "code bloat" -- in other words, "can I optimize my code for better performance?"

For example:

1. IF/ELSE code

In products.tpl, I hard coded a few category exceptions, such as:

Code:

{if $usertype eq "C" and $cat eq "6" or $cat eq "5" }
{include file="customer/main/products_t2.tpl" products=$products}

{elseif $usertype eq "C" and $cat ne "8" and $config.Appearance.products_per_row ne "" and $config.Appearance.products_per_row gt 0 and $config.Appearance.products_per_row lt 4 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")}
{include file="customer/main/products_t.tpl" products=$products}

{else}
{if $products}


Do these if/elses slow me down? Is there a better way to do this?

2. COMMENTED OUT CODE ?

Does commented out code have any impact on performance? Should it be removed? How does the server look at commented out code?

In many (most) of the .php pages, the X-Cart copyright notice is a big old paragraph. I would imagine that removing the copyright notice would probably be in violation of the license...
Quote:

2.3 Proprietary Notices. You may not remove, disable, modify, or tamper with
any copyright, trademark or other proprietary notices and legends contained
within the code of the Software.
but how much overhead are we wasting when EVERY php page has identical commented out text? Would we be gaining anything (assuming x-cart allowed this) if we made the copyright notice a one-liner? Does this matter (as far as performance) ?

Basically, can we streamline performance by removing commented out code and tweaking if/else statements? Or if it doesn't matter, that's good to know... but if an expert could give me a yes/no/don't worry about it, I'd appreciate it.

Thanks,

Jeremy

geckoday 09-16-2006 06:44 AM

Re: Code Bloat?
 
None of the above is anything of concern performance-wise. Do watch out for {math ...} smarty tags as they are very expensive particularly where they are inside a {section ..} ... {/section} or {foreach ...} ... {/foreach}. X-Cart uses them too much for no good reason. Smarty supports most simple math directly without using the {math ...} tag and has a {counter} tag that could be used to replace a lot of X-Cart {math}.

B00MER 09-16-2006 11:23 AM

Re: Code Bloat?
 
...Or they could just do the math within php, or simply use {php} instead of {math} and do the math cals. upon global or smarty scoped variables/arrays.

eval function, one letter away from evIl ! :)


All times are GMT -8. The time now is 06:04 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.