Simplify the following code: nsCOMPtr<nsIDocShell> docShell(bc->GetDocShell());…
- User
Simplify the following code: nsCOMPtr docShell(bc->GetDocShell()); MOZ_ASSERT(docShell);
nsCOMPtr sgo = docShell->GetScriptGlobalObject();
Assistant
There are no obvious ways to simplify this code. It could potentially be wrapped in a function that takes
bcas a parameter and returnssgo, but without context it's impossible to decide if this would be beneficial.Here is the code with minimal modifications for readability:
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(bc, &nsIDocShell::id); MOZ_ASSERT(docShell, "Failed to get docShell"); nsCOMPtr<nsIScriptGlobalObject> sgo; docShell->GetScriptGlobalObject(getter_AddRefs(sgo));
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.