Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Code Bloat?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #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
  #2  
Old 09-16-2006, 06:44 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default 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}.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #3  
Old 09-16-2006, 11:23 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default 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 !
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:26 AM.

   

 
X-Cart forums © 2001-2020