Skip to content

Commit 43f6403

Browse files
committed
Revert "perf(NODE-6356): Improve serialization performance (#709)"
This reverts commit 61537f5.
1 parent dbeda2f commit 43f6403

File tree

7 files changed

+202
-249
lines changed

7 files changed

+202
-249
lines changed

src/bson_value.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { BSON_MAJOR_VERSION } from './constants';
22
import { type InspectFn } from './parser/utils';
3-
import { BSON_VERSION_SYMBOL } from './constants';
43

54
/** @public */
65
export abstract class BSONValue {
76
/** @public */
87
public abstract get _bsontype(): string;
98

109
/** @internal */
11-
get [BSON_VERSION_SYMBOL](): typeof BSON_MAJOR_VERSION {
10+
get [Symbol.for('@@mdb.bson.version')](): typeof BSON_MAJOR_VERSION {
1211
return BSON_MAJOR_VERSION;
1312
}
1413

src/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/** @internal */
22
export const BSON_MAJOR_VERSION = 6;
33

4-
/** @internal */
5-
export const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
6-
74
/** @internal */
85
export const BSON_INT32_MAX = 0x7fffffff;
96
/** @internal */

src/decimal128.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class Decimal128 extends BSONValue {
142142
super();
143143
if (typeof bytes === 'string') {
144144
this.bytes = Decimal128.fromString(bytes).bytes;
145-
} else if (bytes instanceof Uint8Array || isUint8Array(bytes)) {
145+
} else if (isUint8Array(bytes)) {
146146
if (bytes.byteLength !== 16) {
147147
throw new BSONError('Decimal128 must take a Buffer of 16 bytes');
148148
}

src/extended_json.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
BSON_INT32_MIN,
77
BSON_INT64_MAX,
88
BSON_INT64_MIN,
9-
BSON_MAJOR_VERSION,
10-
BSON_VERSION_SYMBOL
9+
BSON_MAJOR_VERSION
1110
} from './constants';
1211
import { DBRef, isDBRefLike } from './db_ref';
1312
import { Decimal128 } from './decimal128';
@@ -359,7 +358,7 @@ function serializeDocument(doc: any, options: EJSONSerializeOptions) {
359358
doc != null &&
360359
typeof doc === 'object' &&
361360
typeof doc._bsontype === 'string' &&
362-
doc[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION
361+
doc[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION
363362
) {
364363
throw new BSONVersionError();
365364
} else if (isBSONType(doc)) {

src/parser/calculate_size.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function calculateElement(
8181
if (
8282
value != null &&
8383
typeof value._bsontype === 'string' &&
84-
value[constants.BSON_VERSION_SYMBOL] !== constants.BSON_MAJOR_VERSION
84+
value[Symbol.for('@@mdb.bson.version')] !== constants.BSON_MAJOR_VERSION
8585
) {
8686
throw new BSONVersionError();
8787
} else if (value == null || value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {

0 commit comments

Comments
 (0)