Closed Bug 500306 Opened 15 years ago Closed 15 years ago

lazy-init annotation service statements

Categories

(Toolkit :: Places, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: dietrich, Assigned: mak)

References

Details

(Keywords: perf, Whiteboard: [tsnap][ts])

Attachments

(1 file, 2 obsolete files)

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.
Attached patch wip (obsolete) — Splinter Review
Assignee: nobody → dietrich
Attachment #384985 - Flags: review?(mak77)
Whiteboard: [tsnap]
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)
i verified the above, both point to 0, so all ifs are returning true this way
Whiteboard: [tsnap] → [tsnap][ts]
Depends on: 531151
stealing bugs around :p
Assignee: dietrich → mak77
Status: NEW → ASSIGNED
Attached patch patch v1.0 (obsolete) — Splinter Review
This one should work.
Attachment #384985 - Attachment is obsolete: true
Attached patch patch v1.1Splinter Review
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)
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+
sure but would not change anything, the macro is expanded by the compiler
and, as a personal preference, i prefer having macros before code
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.

Attachment

General

Created:
Updated:
Size: