AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved a small question: fgets or read_file, which is faster? (https://forums.alliedmods.net/showthread.php?t=303280)

zkfpk6 11-30-2017 21:04

a small question: fgets or read_file, which is faster?
 
i need read more than 5000 lines..

EFFx 12-01-2017 05:03

Re: a small question: fgets or read_file, which is faster?
 
fgets.

HamletEagle 12-01-2017 06:04

Re: a small question: fgets or read_file, which is faster?
 
Don't use read_file/write_file.

aron9forever 12-01-2017 06:23

Re: a small question: fgets or read_file, which is faster?
 
https://wiki.alliedmods.net/Optimizi...)#File_Writing


Quote:

Originally Posted by HamletEagle (Post 2563850)
Don't use read_file/write_file.

these could use a deprecation warning in 1.8.3 like client_disconnect

HamletEagle 12-01-2017 08:09

Re: a small question: fgets or read_file, which is faster?
 
Quote:

Originally Posted by aron9forever (Post 2563854)
https://wiki.alliedmods.net/Optimizi...)#File_Writing




these could use a deprecation warning in 1.8.3 like client_disconnect

I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.

DjSoftero 12-01-2017 09:45

Re: a small question: fgets or read_file, which is faster?
 
Quote:

Originally Posted by HamletEagle (Post 2563873)
I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.

so I just wrote crap ton of config file reading just to recode everything. nice

Arkshine 12-03-2017 17:50

Re: a small question: fgets or read_file, which is faster?
 
read_file/write_file are just inefficient if you need to process them more than one time at once.

zkfpk6 12-03-2017 19:29

Re: a small question: fgets or read_file, which is faster?
 
thank u all bro, same as i guess.

aron9forever 12-04-2017 06:17

Re: a small question: fgets or read_file, which is faster?
 
Quote:

Originally Posted by DjSoftero (Post 2563889)
so I just wrote crap ton of config file reading just to recode everything. nice

shouldn't matter if you only do the file parsing once per map (like to read a config)

Quote:

Originally Posted by HamletEagle (Post 2563873)
I'm not entirely sure, client_disconnect is deprecated because it wasn't working quite right. write_file/read_file are working, they are just inefficient. That's up to Arkshine I guess.

true, but there is no reason to use *_file instead of f*(), maybe no reason to keep them except backwards compatibility, so it should be avoided for newly written scripts

I'm also considering which topics is google more likely to fetch when people search "amxx write to file" or "amxx read from file", also this tut which popped up for me https://forums.alliedmods.net/showthread.php?t=46218 which although explains both methods quite well, a lot of newbs might be tempted to go for "quick and easy"

this is kind of what happened with mysql_*() functions in PHP, technically not broken but still deprecated due to more secure stuff being added, yet still too many people use it

zkfpk6 12-04-2017 22:46

Re: a small question: fgets or read_file, which is faster?
 
Quote:

Originally Posted by aron9forever (Post 2564455)
shouldn't matter if you only do the file parsing once per map (like to read a config)


true, but there is no reason to use *_file instead of f*(), maybe no reason to keep them except backwards compatibility, so it should be avoided for newly written scripts

I'm also considering which topics is google more likely to fetch when people search "amxx write to file" or "amxx read from file", also this tut which popped up for me https://forums.alliedmods.net/showthread.php?t=46218 which although explains both methods quite well, a lot of newbs might be tempted to go for "quick and easy"

this is kind of what happened with mysql_*() functions in PHP, technically not broken but still deprecated due to more secure stuff being added, yet still too many people use it

yeah i saw that tutorial before i asked, but he didn't say which is more faster...i have a little OCD when write codes lol, i think this is a good things for every programer.


All times are GMT -4. The time now is 13:54.

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