AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Optimum way to read a file (https://forums.alliedmods.net/showthread.php?t=236625)

connoisseur 03-08-2014 12:26

[HELP] Optimum way to read a file
 
I coded a plugin that requires to read a file which contains 50-60 steam ids.
Currently, it reads the file whenever a player connects.
Which way is optimum?
Reading the file everytime or using an array to store its contents once and reading them instead?

ddhoward 03-08-2014 12:31

Re: [HELP] Optimum way to read a file
 
Doing something once, or doing something multiple times?

Once. ;)

connoisseur 03-08-2014 12:40

Re: [HELP] Optimum way to read a file
 
Quote:

Originally Posted by ddhoward (Post 2109190)
Doing something once, or doing something multiple times?

Once. ;)

Agreed. But actually my query was something else.
Let me put it this way.
Does it take more time & cpu consumption to read a file than looping through an array?

ddhoward 03-08-2014 12:41

Re: [HELP] Optimum way to read a file
 
Yes, ridiculously so.

Kiske 03-08-2014 14:14

Re: [HELP] Optimum way to read a file
 
Reading a file whenever a user connect is a poor way in this case.
You can use a trie instead of an array.

connoisseur 03-09-2014 09:35

Re: [HELP] Optimum way to read a file
 
Quote:

Originally Posted by Kiske (Post 2109249)
Reading a file whenever a user connect is a poor way in this case.
You can use a trie instead of an array.

Yep. Applied both trie and array combination. I saw Advanced Bans code. It was using that method.
Trie for finding the steam id, and array contained the rest of the necessary data.

OvidiuS 03-09-2014 21:57

Re: [HELP] Optimum way to read a file
 
You could use TrieSetArray/TrieGetArray; https://forums.alliedmods.net/showthread.php?t=201872

ConnorMcLeod 03-10-2014 01:55

Re: [HELP] Optimum way to read a file
 
Quote:

Originally Posted by connoisseur (Post 2109594)
Applied both trie and array combination.

Quote:

Originally Posted by OvidiuS (Post 2109891)
You could use TrieSetArray/TrieGetArray

He could.



Best option could depend on content you have to store.


All times are GMT -4. The time now is 20:27.

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