Replace return await promise with return promise

Awaiting a promise before returning it doesn't make sense if the await
isn't in a try/catch as awaiting forces a function to be async and thus
turns its return value and any error it might throw into a promise.
Worse than that, it can result in an unnecessary context switch which
could be bad for performance.
This commit is contained in:
glacambre 2018-12-25 10:00:01 +01:00
parent c2324d68a7
commit ab196175ac
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
5 changed files with 10 additions and 10 deletions

View file

@ -249,7 +249,7 @@ export async function editor(file: string, content?: string) {
} else {
await run(editorcmd + " " + file)
}
return await read(file)
return read(file)
}
export async function read(file: string) {

View file

@ -1838,7 +1838,7 @@ async function idFromIndex(index?: number | "%" | "#" | string): Promise<number>
index: index - 1,
}))[0].id
} else {
return await activeTabId()
return activeTabId()
}
}
@ -2500,9 +2500,9 @@ for (let fn in cmdframe_fns) {
/**
* Returns the current URL. For use with [[composite]].
*/
//#background
//#content
export async function get_current_url() {
return (await activeTab()).url
return window.location.href
}
/**
@ -3382,13 +3382,13 @@ export async function hint(option?: string, selectors?: string, ...rest: string[
let hintTabOpen = async (href, active = !rapid) => {
let containerId = await activeTabContainerId()
if (containerId) {
return await openInNewTab(href, {
return openInNewTab(href, {
active,
related: true,
cookieStoreId: containerId,
})
} else {
return await openInNewTab(href, {
return openInNewTab(href, {
active,
related: true,
})

View file

@ -183,7 +183,7 @@ export class AutoContain implements IAutoContain {
)
}
}
return await Container.getId(aucons[aukeyarr[0]])
return Container.getId(aucons[aukeyarr[0]])
}
}
}

View file

@ -174,7 +174,7 @@ export function fromString(
* @returns An array representation of all containers.
*/
export async function getAll(): Promise<any[]> {
return await browser.contextualIdentities.query({})
return browser.contextualIdentities.query({})
}
/** Fetches the cookieStoreId of a given container

View file

@ -60,7 +60,7 @@ export async function activeTabContainerId() {
//#content_helper
export async function ownTab() {
// Warning: this relies on the owntab_background listener being set in messaging.ts in order to work
return await browser.runtime.sendMessage({ type: "owntab_background" })
return browser.runtime.sendMessage({ type: "owntab_background" })
}
//#content_helper
@ -79,7 +79,7 @@ export async function ownTabContainer() {
export async function activeTabContainer() {
let containerId = await activeTabContainerId()
if (containerId !== "firefox-default")
return await browserBg.contextualIdentities.get(containerId)
return browserBg.contextualIdentities.get(containerId)
else
throw new Error(
"firefox-default is not a valid contextualIdentity (activeTabContainer)",