Skip to content

Commit

Permalink
perf(core): change sha1 to xxhash
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Feb 4, 2023
1 parent 2d7703a commit 7f43821
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 6 deletions.
104 changes: 100 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
]
},
"dependencies": {
"@node-rs/xxhash": "^1.3.0",
"@nuxtjs/opencollective": "0.3.2",
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/injector/module-token-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DynamicModule } from '@nestjs/common';
import { Type } from '@nestjs/common/interfaces/type.interface';
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
import { isFunction, isSymbol } from '@nestjs/common/utils/shared.utils';
import { xxh32 } from '@node-rs/xxhash';
import stringify from 'fast-safe-stringify';
import { createHash } from 'crypto';

const checkClass = 'class ';
const checkClassLength = checkClass.length;
Expand Down Expand Up @@ -68,7 +68,7 @@ export class ModuleTokenFactory {
}

private hashString(value: string): string {
return createHash('sha1').update(value).digest('hex');
return xxh32(value).toString();
}

private replacer(key: string, value: any) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"dependencies": {
"@nuxtjs/opencollective": "0.3.2",
"@node-rs/xxhash": "^1.3.0",
"fast-safe-stringify": "2.1.1",
"iterare": "1.2.1",
"path-to-regexp": "3.2.0",
Expand Down

0 comments on commit 7f43821

Please sign in to comment.