Question about YSI
#5

Quote:

'YSI/y_va'

YSI_Coding\y_va* (if no warning is displayed, you are using an older version of YSI and I can recommend you to upgrade to the latest YSI).

Quote:

It's more simple and i don't need to count and dont need to use EOS.

In normal situations you don't need to use EOS, this goes automatically. I merely showed you how strings work. Eg. doing this:
pawn Code:
new myArray[15];
format(myArray, 15, "Hello world!"); //Note that in this situation, using [myArray = "Hello world!";] would be a much better choice
Will automatically set the array to (something like):
Code:
{'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', EOS, '', '', EOS}
.

As for being afraid of wasting memory. Just make sure you don't use way too much cells like some people do (eg. using 512 cells for a client message).
Here's a pretty safe SendClientMessageFormatted(ToAll) function:
pawn Code:
SendClientMessageFormatted(playerid, color, const format[], va_args<>)
{
    new __scmfStr[144];
    va_format(__scmfStr, 144, format, va_start<3>);
    if (playerid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, color, __scmfStr);
    else return SendClientMessageToAll(color, __scmfStr);
}
#define SendClientMessageToAllFormatted(%0) SendClientMessage(INVALID_PLAYER_ID, %0)
Some people tend to use 'static' instead of 'new'. By doing this it's allocated to the global memory (and thus also the amx size -no issue though) instead of the stack. This could mean it's a bit faster but I don't think it makes that much of a difference. static variables also remember their value (unless if it's a file-global variable/symbol, then it's a symbol that's only available for that file) so if sensitive data was sent using above function, it's stored in the server(/system)'s memory.

Anyway, to go to your question:
Quote:

I want to know if 'y_va' will use more CPU MEM than EOS.

EOS isn't a system like y_va. EOS is just a macro for '\0', which is just a character. You are trying to compare a character to a system (that's like comparing the letter K with a TV). And even y_va would use EOS if needed, because that's just how PAWN works. All string functions use the null terminator to determine the length of the string. If you have this array/string:
pawn Code:
new myArray[] = "Hello there cruel cruel beautifull world!";
myArray[5] = EOS; //[5] is the space after Hello
printf("Length of myArray is %d", strlen(myArray));
print(myArray);
It would print:
Code:
Length of myArray is 5
Hello
The null terminator was found after 'o' so it assumes it's the end of the string. The rest of the array is then totally ignored. Some (old) 'erase' functions set the null terminator to the first index of an array. This does not erase the string but merely
I do get what you mean though, and remember this:
Y_L3ss is all about optimalisations. In general you're best of using YSI's library, so just go for it. Also, GTA SA/SAMP is pretty old. Systems these days should not have problems with it (unless if you're using a VPS with crap CPUs -large gamemodes could then run into problems).


Also I'm a bit tired at this moment so if there are typo's or perhaps some information that's a tad wrong I offer you my humble and sincere apologies.
Reply


Messages In This Thread
Question about YSI - by MarianImmortalGod - 03.07.2020, 15:09
Re: Question about YSI - by MarianImmortalGod - 03.07.2020, 21:22
Re: Question about YSI - by Kwarde - 04.07.2020, 12:13
Re: Question about YSI - by MarianImmortalGod - 04.07.2020, 12:34
Re: Question about YSI - by Kwarde - 04.07.2020, 21:47
Re: Question about YSI - by MarianImmortalGod - 04.07.2020, 22:19
Re: Question about YSI - by Kwarde - 04.07.2020, 22:54
Re: Question about YSI - by MarianImmortalGod - 04.07.2020, 23:59

Forum Jump:


Users browsing this thread: 1 Guest(s)