Fix a perf issue caused by cloning schemaObj (#101)

Co-authored-by: Ray Chen <raychen@microsoft.com>
This commit is contained in:
Yufei Huang 2020-07-23 14:49:46 +08:00 коммит произвёл GitHub
Родитель d7a8005235
Коммит 9d7cbb6dce
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 0 добавлений и 5 удалений

Просмотреть файл

@ -25,7 +25,6 @@
'use strict';
var _ = require('lodash');
var cloneDeep = require('clone-deep');
var formatGenerators = require('./validation/format-generators');
var formatValidators = require('./validation/format-validators');
var customValidators = require('./validation/custom-zschema-validators');
@ -471,10 +470,6 @@ module.exports.removeCirculars = function (obj) {
* @returns {object} Object containing the errors and warnings of the validation
*/
module.exports.validateAgainstSchema = function (validator, schema, value, schemaPath, isResponse, options) {
// Clone the schema as z-schema alters the provided document (https://github.com/zaggino/z-schema/issues/160#issuecomment-214901835).
// Original lodash's deep clone was used but during memory profiling we've found lodash's deep clone takes a lot of CPU, according to this benchmark (https://github.com/ahmadnassri/benchmark-node-clone) and load testing, we've decided to replace lodash with this deep-clone library
schema = cloneDeep(schema);
var response = {
errors: [],
warnings: []