On May 13, 2008, at 12:38 AM, Daniel Vollmer wrote:

Salutations!

I'm parsing a rather large text-file (usually >20MB) and in doing so I'm iterating over its lines with [String getParagraphStart::::]. I've found a rather noticeable speed-up in the parsing operation if I create the string in question from an NSData object (created via initWithContentsOfMappedFile) using [String initWithData:encoding:].

Now to the questions:
1) Is this safe if the file in question is being moved / deleted / edited during parsing?


No, the system might not map the entire file (depending on size and available resources or implementation choices) so when you read a new, not yet mapped, or previously discarded page it will come from the current state of the file, be it untouched, modified, or deleted. Basically there's no guarantee you'll get the same data that was in the file when you first mapped it if something else modifies or destroys it while it's mapped.


2) Are substrings created from the original string (e.g. substringWithRange etc.) still backed properly after the original string and the NSData object are released?


Yes, they're newly created and individual string objects.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to