Raised This Month: $ Target: $400
 0% 

More efficient way to check an entity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kirewv
Senior Member
Join Date: Oct 2007
Old 06-15-2008 , 18:11   More efficient way to check an entity?
Reply With Quote #1

Let's say I have a group of 50 entites of 6 classtypes.
I want to perform an action on particular entity after aiming at it.

Is it more efficient to check if the entities index falls within a certain number
PHP Code:
if(50 <= entity <= 100)//hypothetical index values
{
do 
stuff;

or

is it more efficient to check if they are of the desired class
PHP Code:
GetEntityClassname(entity,string,length);
if (
string desiredclass)
{
do 
someting;

kirewv is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 06-15-2008 , 18:51   Re: More efficient way to check an entity?
Reply With Quote #2

It is way more efficient to the computer to compare numbers rather then compare strings.

I am not quite sure what you are trying to do.
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
BAILOPAN
Join Date: Jan 2004
Old 06-17-2008 , 01:06   Re: More efficient way to check an entity?
Reply With Quote #3

String comparisons are "fast" but there is a faster solution. In theory, SourceMod could cache the internal function "vtables" of each entity type. Then we could have something like...

IsEntityType(ent, "type") and it would be able to compute it in O(k) time for you.

Maybe something to file a feature request for. There's definitely a solution to optimizing your problem, and it's important for high-profile callbacks.
__________________
egg
BAILOPAN is offline
Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode