Closed Bug 1693530 Opened 5 years ago Closed 5 years ago

Add nsBaseHashtable::TryLookupOrInsertWith variant that accepts a functor returning a mozilla::Result

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(1 external file)

It would be desirable if we were able to write something like:

MOZ_TRY_UNWRAP(val, hashtable.LookupOrInsertWith(key, []() -> Result<DataType, nsresult> {
  auto res = MakeUnique<Foo>();

  MOZ_TRY(res->DoSomething());

  return res;
});

Otherwise, we need to resort to WithEntryHandle in such a case and get very deep nesting typically.

Summary: Migrate nsBaseHashtable::LookupOrInsertWith that accepts a functor returning a mozilla::Result → Add nsBaseHashtable::LookupOrInsertWith variant that accepts a functor returning a mozilla::Result
Assignee: nobody → sgiesecke
Status: NEW → ASSIGNED
Summary: Add nsBaseHashtable::LookupOrInsertWith variant that accepts a functor returning a mozilla::Result → Add nsBaseHashtable::TryLookupOrInsertWith variant that accepts a functor returning a mozilla::Result
Attachment #9203968 - Attachment description: Bug 1693530 - Add nsBaseHashtable::LookupOrInsertWith variant that accepts a functor returning a mozilla::Result. r=#xpcom-reviewers,janv → Bug 1693530 - Add nsBaseHashtable::TryLookupOrInsertWith variant that accepts a functor returning a mozilla::Result. r=#xpcom-reviewers,janv
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3e8813dd91c1 Add nsBaseHashtable::TryLookupOrInsertWith variant that accepts a functor returning a mozilla::Result. r=janv,xpcom-reviewers,nika
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: