Skip to content

Commit e4fe848

Browse files
committed
fix: zero copy of connectionId and connectionIdPeer
1 parent 5ac3c3b commit e4fe848

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/QUICConnection.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ class QUICConnection {
400400
* This is the source connection ID.
401401
*/
402402
public get connectionId() {
403-
return new QUICConnectionId(this.conn.sourceId());
403+
const sourceId = this.conn.sourceId();
404+
// Zero copy construction of QUICConnectionId
405+
return new QUICConnectionId(
406+
sourceId.buffer,
407+
sourceId.byteOffset,
408+
sourceId.byteLength,
409+
);
404410
}
405411

406412
/**
@@ -409,7 +415,13 @@ class QUICConnection {
409415
*/
410416
@ready(new errors.ErrorQUICConnectionNotRunning())
411417
public get connectionIdPeer() {
412-
return new QUICConnectionId(this.conn.destinationId());
418+
const destinationId = this.conn.destinationId();
419+
// Zero copy construction of QUICConnectionId
420+
return new QUICConnectionId(
421+
destinationId.buffer,
422+
destinationId.byteOffset,
423+
destinationId.byteLength,
424+
);
413425
}
414426

415427
/**

0 commit comments

Comments
 (0)