[Lazarus] Reworked ReadFileToString to support Linux virtual files
Juha Manninen
juha.manninen62 at gmail.com
Sat Nov 9 10:50:13 CET 2019
On Fri, Nov 8, 2019 at 11:09 PM AlexeyT via lazarus
<lazarus at lists.lazarus-ide.org> 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
More information about the lazarus
mailing list