From 45a3ed0fcf2c0170607505a1550fb15896e705fd Mon Sep 17 00:00:00 2001 From: Yechezkel Deren Date: Wed, 13 Sep 2023 15:16:33 +0300 Subject: [PATCH] perf: Improve performance of recursive pointer iterations (#8741) --- src/RestQuery.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/RestQuery.js b/src/RestQuery.js index 538d87d4..96a52ec1 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -1066,11 +1066,7 @@ function includePath(config, auth, response, path, restOptions = {}) { // Returns a list of pointers in REST format. function findPointers(object, path) { if (object instanceof Array) { - var answer = []; - for (var x of object) { - answer = answer.concat(findPointers(x, path)); - } - return answer; + return object.map(x => findPointers(x, path)).flat(); } if (typeof object !== 'object' || !object) {