raw rows post-processing, (im)mutable?
raw rows post-processing, (im)mutable?
- Subject: raw rows post-processing, (im)mutable?
- From: OC <email@hidden>
- Date: Wed, 24 Feb 2016 01:04:56 +0100
Hello there,
well, having fetched raw rows all right, I need to post-process them, essentially by checking each fetched raw row, and to some of them (not all, but many) adding couple of extra attributes.
The safe and clean approach would, of course, be something like
=== safe&clean ===
def fetchedRawRows=ec.objectsWithFetchSpecification(fs)
def result=new NSMutableArray()
for (rr in fetchedRawRows)
if (needToAddSomething(rr))
def nrr=rr.mutableClone()
nrr.setObjectForKey(...) // more of these
nrr.removeObjectForKey(...) // when post-processed, some fetched BLOBs are not needed anymore, NSData will be GCed in due time
result.addObject(nrr)
} else result.addObject(rr)
return result
===
in practice though those returned raw rows seem to be mutable (com.webobjects.eocontrol._EOMutableKnownKeyDictionaries, whatever that means), and the unsafe unclean but considerably more efficient approach actually seems to work:
=== quick&dirty ===
def fetchedRawRows=ec.objectsWithFetchSpecification(fs)
for (rr in fetchedRawRows)
if (needToAddSomething(rr)) {
rr.setObjectForKey(...) // more of these
rr.removeObjectForKey(...) // unlike above, might be GCed immediately if need be
}
return fetchedRawRows
===
Since fetchedRawRows will tend to be rather at the huge side, quite probably the difference will be notable.
Can someone say by experience or by a deep knowledge that the quick&dirty approach is actually safe? Or, contrariwise, that if I embrace it, sooner or later the hell will break loose?
Thanks!
OC
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden