fix: remove unnecessary URL allocation (#2554)

This commit is contained in:
Marvin Hagemeister
2024-06-27 12:34:56 +02:00
committed by GitHub
parent bfb5753ecb
commit 138d4c457c
4 changed files with 5 additions and 3 deletions
+1
View File
@@ -203,6 +203,7 @@ export class App<State> {
const { params, handlers } = matched;
const ctx = new FreshReqContext<State>(
req,
url,
conn,
params,
this.config,
+2 -1
View File
@@ -111,6 +111,7 @@ export class FreshReqContext<State>
constructor(
req: Request,
url: URL,
info: Deno.ServeHandlerInfo | Deno.ServeUnixHandlerInfo,
params: Record<string, string>,
config: ResolvedFreshConfig,
@@ -118,7 +119,7 @@ export class FreshReqContext<State>
islandRegistry: ServerIslandRegistry,
buildCache: BuildCache,
) {
this.url = new URL(req.url);
this.url = url;
this.req = req;
this.info = info;
this.params = params;
+1
View File
@@ -78,6 +78,7 @@ export function serveMiddleware<T>(
const ctx = new FreshReqContext<T>(
req,
new URL(req.url),
DEFAULT_CONN_INFO,
{},
config,
+1 -2
View File
@@ -5,8 +5,7 @@ import { define } from "../utils/state.ts";
export const handler = define.handlers({
GET(ctx) {
const url = new URL(ctx.req.url);
const search = new URLSearchParams(url.search);
const search = new URLSearchParams(ctx.url.search);
const vote = search.get("vote");
return page({ vote });
},