Closed
Bug 500306
Opened 15 years ago
Closed 15 years ago
lazy-init annotation service statements
Categories
(Toolkit :: Places, defect)
Toolkit
Places
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a1
People
(Reporter: dietrich, Assigned: mak)
References
Details
(Keywords: perf, Whiteboard: [tsnap][ts])
Attachments
(1 file, 2 obsolete files)
18.19 KB,
patch
|
dietrich
:
review+
|
Details | Diff | Splinter Review |
hm, i thought i filed a bug for this, but can't find it.
idea is that many anno statements aren't needed in the startup path. so this patch just lazy-inits all of them.
needs some cleanup still, but asking quick review on the approach.
Reporter | ||
Comment 1•15 years ago
|
||
Assignee: nobody → dietrich
Attachment #384985 -
Flags: review?(mak77)
Reporter | ||
Updated•15 years ago
|
Whiteboard: [tsnap]
Assignee | ||
Comment 2•15 years ago
|
||
Comment on attachment 384985 [details] [diff] [review]
wip
we could follow the lazy approach, but would be cool to find a way to make it less verbose, having to remember to call an init function before using any statement sounds error-prone. I would prefer a temp stmt = GetAnnoStatement(mDBXXX), or we could inherit an annoStatementScoper from mozIStatementScoper that ensures the query is inited and then starts scoping as usual.
As a first step you should check if aStatement is already defined, no need to init a statement twice, then the structure should be an if-elseif or switch, rather than an if-if.
Btw, i have some concern about the functionality of this code, you are comparing aStatement with mDBxxx properties, but the latter are not yet defined, all of them are pointing to 0. Physical addressed of the COMPtrs are different though. I'm not sure what kind of comparison will be done in this case, the only plausible one would be direct address comparison (&mDBXXX is unique). If this works with an else-if structure it's already doing an address comparison, otherwise all ifs are probably returning true at the first call since aStatement points to 0 as all the mDBXXX.
btw, atm my repository is completely broken and i can't verify that.
Attachment #384985 -
Flags: review?(mak77)
Assignee | ||
Comment 3•15 years ago
|
||
i verified the above, both point to 0, so all ifs are returning true this way
Reporter | ||
Updated•15 years ago
|
Whiteboard: [tsnap] → [tsnap][ts]
Assignee | ||
Comment 4•15 years ago
|
||
stealing bugs around :p
Assignee: dietrich → mak77
Status: NEW → ASSIGNED
Assignee | ||
Comment 5•15 years ago
|
||
This one should work.
Attachment #384985 -
Attachment is obsolete: true
Assignee | ||
Comment 6•15 years ago
|
||
Fix possible shutdown bad conditions.
If you like this approach we could use it in other services too, replacing the single GetXXXStatement methods.
Attachment #417095 -
Attachment is obsolete: true
Attachment #417477 -
Flags: review?(dietrich)
Reporter | ||
Comment 7•15 years ago
|
||
Comment on attachment 417477 [details] [diff] [review]
patch v1.1
>+mozIStorageStatement*
>+nsAnnotationService::GetStatement(const nsCOMPtr<mozIStorageStatement>& aStmt)
>+{
>+#define RETURN_IF_STMT(_stmt, _sql) \
>+ PR_BEGIN_MACRO \
>+ if (address_of(_stmt) == address_of(aStmt)) { \
>+ if (!_stmt) { \
>+ nsresult rv = mDBConn->CreateStatement(_sql, getter_AddRefs(_stmt)); \
>+ NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && _stmt, nsnull); \
>+ } \
>+ return _stmt.get(); \
>+ } \
>+ PR_END_MACRO
>+
>+ if (mShuttingDown)
>+ return nsnull;
could put this before the macro, yes?
r=me otherwise
Attachment #417477 -
Flags: review?(dietrich) → review+
Assignee | ||
Comment 8•15 years ago
|
||
sure but would not change anything, the macro is expanded by the compiler
Assignee | ||
Comment 9•15 years ago
|
||
and, as a personal preference, i prefer having macros before code
Assignee | ||
Comment 10•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
You need to log in
before you can comment on or make changes to this bug.
Description
•