It is currently 05 Sep 2010, 11:11

All times are UTC - 8 hours


Increase Web Traffic

 Page 1 of 1 [ 3 posts ] 
Author Message
 Post subject: Alias to control room specific flags
PostPosted: 17 Oct 2009, 13:21 
User avatar

Joined: 22 Aug 2008, 20:00
Posts: 6
I keep seeing people make add-ons that are room or channel specific. People use several different methods to track channel specific add-ons whether it be tokens, hashes, ini files, or some other crazy method. In my quest to minimalize code spam i use an alias to handle all of that for me. Are there any downfalls in using something like this? (It sure makes code a lot cleaner).

alias isflag { return $iif($istok($hget(HASHNAME,$$1),$$2,4),1,0) }
alias togflag { var %t $hget(HASHNAME,$$1) | hadd HASHNAME $$1 $iif($istok(%t,$$2,4),$remtok(%t,$$2,4),$addtok(%t,$$2,4)) }


Using this, each channel add-on becomes

.$style($isflag(logclone,#)) Log Clones: { togflag  logclone # }


which is much prettier than the alternative.


Offline
 Profile Send private message  
 
 Post subject: Re: Alias to control room specific flags
PostPosted: 17 Oct 2009, 18:26 
User avatar

Joined: 04 Nov 2007, 21:00
Posts: 246
That's a pretty cool idea.

The only thing I have to say about that is using an alias, custom identifier, doubles the time it takes to process the script. Also $iif is slower than using a normal if statement.

That is why I didn't make a bunch of aliases for these things and the reason you don't see $iif used in SoulFly unless it is required.

The performance difference is negligible if you seperate each instance, but when you add up all the instances in the script it makes a difference. That is one of the reasons SoulFly is faster and more stable than other connections even though it seems larger.

Thanks for posting. :)



_________________
    Image
    Image

    Image
Offline
 Profile Send private message  
 
 Post subject: Re: Alias to control room specific flags
PostPosted: 17 Oct 2009, 19:01 
User avatar

Joined: 22 Aug 2008, 20:00
Posts: 6
On an event command or high usage area, i could definitely relate to the performance issue. However, on a submenu pop-up, i will take the less code over performance. There will always be a fine line between efficiency and speed.

Good info on the slow iif's.


Offline
 Profile Send private message  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest

increase web traffic

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron