Raised This Month: $ Target: $400
 0% 

How does pawn handle arrays and which way is better.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-30-2013 , 23:51   Re: How does pawn handle arrays and which way is better.
Reply With Quote #1

Quote:
Originally Posted by .Dare Devil. View Post
Hello, Im pretty curious about arrays like this
PHP Code:
new something[256
now there is
PHP Code:
new something[4// lets do small array for example, i ofcourse prefer always the big ones :)

public myfunction(posvalue)
{
     
something[pos] = value


is it same like this?
PHP Code:
new something0,something1,something2,something3
public myfunction(posvalue)
{
     switch(
pos)
    {
        case 
0something0 value
        
case 1something1 value
        
case 2something2 value
        
case 3something3 value

    
}


the way i understand things right now is that the first code is better and faster way and it does not matter if the array size is big or small, it does not effect the cpu speed.
You can test it to see if it works the same. In your example the difference is likely negligible and you should code for readability/flexibility/maintainability.


Quote:
Originally Posted by .Dare Devil. View Post
I was an idea for creating big array like this Float:chuckdata[8000][3]
so inside of chuckdata are costom areas ( values are in bit )
so i can just easily check that if player is in costom area
PHP Code:
static Float:o[3],ab
pev
(idpev_origino)
for( 
03a++ )  
{
floatround(o[a] + 4000.0)
// i dont know that if its right, i dont know about bits, never tested them and i was thinking that they are useless what is very wrong. I want to check here like if( o[a] != mybit) you know what i mean with that... :)
if( chuckdata[b][a] ~ mybit) return
}

// and now if cpu is here then player is standing in area what is in my database.
// i need to use bits because then i can but more than one areas in one place for example ( and also if area is inside of ohter area, bits will help me. ) 
What in the world are you trying to do here? If you think you need to make an array that big then I would guess that you need to rethink how you are doing it.
__________________

Last edited by fysiks; 04-30-2013 at 23:52.
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-01-2013 , 06:04   Re: How does pawn handle arrays and which way is better.
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
What in the world are you trying to do here? If you think you need to make an array that big then I would guess that you need to rethink how you are doing it.
I would event say more :
What in the world are you trying to do here? If you think you need to make an array that big then I would guess that you need to rethink how you are doing it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 10:57.


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