Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/bundle-size/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ usually do. We repeat this for an increasing number of files.

| code generator | files | bundle size | minified | compressed |
| ------------------- | ----: | ----------: | --------: | ---------: |
| Protobuf-ES | 1 | 132,088 b | 68,483 b | 15,718 b |
| Protobuf-ES | 4 | 134,277 b | 69,993 b | 16,450 b |
| Protobuf-ES | 8 | 137,039 b | 71,764 b | 16,974 b |
| Protobuf-ES | 16 | 147,489 b | 79,745 b | 19,317 b |
| Protobuf-ES | 32 | 175,280 b | 101,763 b | 24,760 b |
| Protobuf-ES | 1 | 132,159 b | 68,489 b | 15,756 b |
| Protobuf-ES | 4 | 134,348 b | 69,996 b | 16,428 b |
| Protobuf-ES | 8 | 137,110 b | 71,767 b | 16,932 b |
| Protobuf-ES | 16 | 147,560 b | 79,748 b | 19,320 b |
| Protobuf-ES | 32 | 175,351 b | 101,766 b | 24,771 b |
| protobuf-javascript | 1 | 104,048 b | 70,320 b | 15,540 b |
| protobuf-javascript | 4 | 130,537 b | 85,672 b | 16,956 b |
| protobuf-javascript | 8 | 152,429 b | 98,044 b | 18,138 b |
Expand Down
12 changes: 6 additions & 6 deletions packages/bundle-size/chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions packages/protobuf/src/from-binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ import type {
import { scalarZeroValue } from "./reflect/scalar.js";
import type { ScalarValue } from "./reflect/scalar.js";
import { reflect } from "./reflect/reflect.js";
import {
BinaryReader,
BinaryWriter,
WireType,
} from "./wire/binary-encoding.js";
import { BinaryReader, WireType } from "./wire/binary-encoding.js";
import { varint32write } from "./wire/varint.js";

/**
* Options for parsing binary data.
Expand Down Expand Up @@ -163,9 +160,14 @@ export function readField(
if (ok) {
message.set(field, val);
} else if (options.readUnknownFields) {
const data = new BinaryWriter().int32(val as number).finish();
const bytes: number[] = [];
varint32write(val as number, bytes);
const unknownFields = message.getUnknown() ?? [];
unknownFields.push({ no: field.number, wireType, data });
unknownFields.push({
no: field.number,
wireType,
data: new Uint8Array(bytes),
});
message.setUnknown(unknownFields);
}
}
Expand Down