[Interest] Simple doubt on file i/o
Arne Dirks
arne.dirks at iathh.de
Thu Jun 27 09:28:03 CEST 2013
On 06/27/2013 08:56 AM, Mandeep Sandhu wrote:
> get(key):
> * Open the file in Read-Only mode.
> * Parse the data and prepare a QMap of the key-value pairs.
> * Close the file
> * Return the value for the key
>
> set(key, value):
> * Open the file in Read-Only mode.
> * Parse the data and prepare a QMap of the key-value pairs.
> * Close the file
> * Open the file in Write-Only & Truncate mode
> * Insert the new key-value in the map
> * Write the map
> * Close the file
Is there a reason why you read the file every time you get/set
something? Couldn't you read the file once during application startup,
store the data in a map and only write it out again when your
application terminates, provided anything has changed at all?
arne
More information about the Interest
mailing list