Closed
Bug 328196
Opened 18 years ago
Closed 18 years ago
nsDiskCacheDevice: Memory and codesize optimisations
Categories
(Core :: Networking: Cache, defect)
Core
Networking: Cache
Tracking
()
VERIFIED
FIXED
People
(Reporter: alfredkayser, Assigned: alfredkayser)
References
Details
Attachments
(1 file)
24.52 KB,
patch
|
darin.moz
:
review+
|
Details | Diff | Splinter Review |
Some minor optimisations for nsDiskCacheDevice, including two malloc removals: One in the VisitRecord, and one for the mCacheMap member. In nsDiskCacheEvictor::VisitRecord(nsDiskCacheRecord * mapRecord) - // XXX FIXME compare clientID's without malloc This can be easily fixed, by doing a direct check of the clientID in the diskEntry, as follows: + // Compare clientID's without malloc + if ((diskEntry->mKeySize <= mClientIDSize) || + (diskEntry->mKeyStart[mClientIDSize] != ':') || + (memcmp(diskEntry->mKeyStart, mClientID, mClientIDSize) != 0)) { * Make mCacheMap a static member of nsDiskCacheDevice, so that we can remove the 'new nsDiskCacheMap' and the checking for null pointer, and that all references to mCacheMap stuff goes directly from nsDiskCacheMap. - nsDiskCacheMap * mCacheMap; + nsDiskCacheMap mCacheMap; - mCacheMap = new nsDiskCacheMap; - if (!mCacheMap) - return NS_ERROR_OUT_OF_MEMORY; Also DoomRecord in nsDiskCacheMap can be removed by calling DeleteRecord directly. Also DeleteRecordAndStorage is only called from one place, and can be replaced by calling DeleteRecord and DeleteStorage directly from that place. The 'InitializeCacheDirectory()' is only called from one place (OpenDiskCache), and the logic of OpenDiskCache is easier to follow if the logic from 'InitializeCacheDirectory()' is placed inline (which is 'create directory, open cache map at that directory'). From both visitors, the mDevice member can be removed, and from the EntryInfoVisitor, the mResult member is not used. Also made the following private: - PRBool Initialized() { return mInitialized; } - nsresult Shutdown_Private(PRBool flush);
Assignee | ||
Comment 1•18 years ago
|
||
Comment 2•18 years ago
|
||
Any interest in fixing bug 321456 along with this one?
Assignee | ||
Comment 3•18 years ago
|
||
Codesize savings is about 1.5K: OLD: 243.108 nkcache_s.lib NEW: 241.490 nkcache_s.lib
Assignee | ||
Comment 4•18 years ago
|
||
It is better keep bug 321456 separate, but I will look into that as well.
Comment 5•18 years ago
|
||
Comment on attachment 212739 [details] [diff] [review] First version, incl. all described optimalizations r=darin, sorry for the long delay.
Attachment #212739 -
Flags: review?(darin) → review+
Comment 6•18 years ago
|
||
fixed-on-trunk heh.. i was thinking of a different bug when i made that last comment ;-)
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 7•15 years ago
|
||
See also bug 405407 for more memory & disk optimisations...
Blocks: 405407
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•