Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-02

TMemIniFile proposed patch

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Patrick Chevalley

Hi,

I notice my application take a lot of time while writing it's configuration to a .ini file using TMemIniFile, up to 10 seconds for a 12K file. With the proposed patch it do the same instantly.

This is because TMemIniFile do not implement it's own WriteString function but use TIniFile one.
This imply to write the full file each time a string is changed.

Delphi TMemIniFile use a buffered write as describe in this paragraph extracted from the Delphi help:

Unlike the TIniFile object, which also encapsulates INI file data, TMemIniFile buffers all changes to the INI file. The INI file is read once, when the object is first created. ... After the data is read, any changes to the data are stored in memory. To write the data from memory back to the associated INI file, call the UpdateFile method.

There is no problem while reading the file because TIniFile.ReadString is already buffered contrary to the Delphi implementation.

I hope this change to fcl/inc/inifiles.pp (or a variation) can be applied to the fcl.

Patrick Chevalley

Reply by email

Patrick Chevalley

Hi,

I notice my application take a lot of time while writing it's configuration to a .ini file using TMemIniFile, up to 10 seconds for a 12K file. With the proposed patch it do the same instantly.

This is because TMemIniFile do not implement it's own WriteString function but use TIniFile one.
This imply to write the full file each time a string is changed.

Delphi TMemIniFile use a buffered write as describe in this paragraph extracted from the Delphi help:

Unlike the TIniFile object, which also encapsulates INI file data, TMemIniFile buffers all changes to the INI file. The INI file is read once, when the object is first created. ... After the data is read, any changes to the data are stored in memory. To write the data from memory back to the associated INI file, call the UpdateFile method.

There is no problem while reading the file because TIniFile.ReadString is already buffered contrary to the Delphi implementation.

I hope this change to fcl/inc/inifiles.pp (or a variation) can be applied to the fcl.

Patrick Chevalley

Reply by email

Florian Klaempfl
to Patrick Chevalley

Patrick Chevalley wrote:

Applied, thx.

Show quoted text 5 lines
Hi, I notice my application take a lot of time while writing it's configuration to a .ini file using TMemIniFile, up to 10 seconds for a 12K file. With the proposed patch it do the same instantly.

Reply by email