Re: [Lazarus] Reworked ReadFileToString to support Linux virtual files

2019-11-09 Thread Juha Manninen via lazarus
On Fri, Nov 8, 2019 at 11:09 PM AlexeyT via lazarus
 wrote:
> Last attached demo contains my reworked function (after the fix it works
> pretty fast, i tested it). Can you apply at least this function? The
> issue can be opened - issue is about IDE. The function is reworked to
> support Linux virtual files like /proc/version, /proc/meminfo.

I am hesitant to apply it because IMO it is not well optimized. It
uses TFileStream, then a char buffer and then the Result string. Data
is moved between them 3 times, isn't it?
Another reason for hesitation: we don't have any acute bug concerning
function ReadFileToString() that needs fixing. Yes I know the current
function does not work with virtual files in Unix systems. Fixing that
is a good idea but the new function should be as fast or faster than
the current one which calls FileSize(). What is the overhead caused by
FileSize()? I don't know but the speed of potential ReadFileToString()
replacements should be compared. Did you compare them?
If somebody comes up with a good optimised version, I promise to apply it.

One problem is also that you often concentrate on trivial unimportant
details of Lazarus sources instead of fixing real bugs.
I know real bugs require diving deep into the code, hours of studying
and debugging. It is harder than the trivial changes but there is no
alternative when fixing the really nasty bugs.

Juha
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Reworked ReadFileToString to support Linux virtual files

2019-11-09 Thread Michael Van Canneyt via lazarus



On Sat, 9 Nov 2019, AlexeyT via lazarus wrote:


https://bugs.freepascal.org/view.php?id=36145

Last attached demo contains my reworked function (after the fix it works 
pretty fast, i tested it). Can you apply at least this function? The 
issue can be opened - issue is about IDE. The function is reworked to 
support Linux virtual files like /proc/version, /proc/meminfo.


Concerning
"Btw, i could not make this func using "file of byte" or "file" types for BlockRead, 
in that cases i always got IOResult=5 (Access denied) so i 've used TextFile type (IOResult is ok)."


file of byte or untyped files are always opened read/write.
The FileMode variable can be set to avoid that.

Michael.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus