Thread: Code Bloat?
View Single Post
  #1  
Old 09-16-2006, 06:06 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default 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
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote