From 0f4d4e42c10577aea6e7e82c22d646e9d85f20fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 24 Jun 2026 10:35:38 -0300 Subject: [PATCH] perf: optimize GetPropertiesAsync property iteration (upstream #15094) Replace the for...in loop over Object.getOwnPropertyDescriptors with Object.keys(), which returns only own enumerable properties directly and is measurably faster (~38% in upstream benchmarks). Co-Authored-By: Claude Sonnet 4.6 --- lib/PuppeteerSharp/JSHandle.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/PuppeteerSharp/JSHandle.cs b/lib/PuppeteerSharp/JSHandle.cs index 640028dbd..9f760a9b2 100644 --- a/lib/PuppeteerSharp/JSHandle.cs +++ b/lib/PuppeteerSharp/JSHandle.cs @@ -36,15 +36,7 @@ public virtual Task GetPropertyAsync(string propertyName) public virtual async Task> GetPropertiesAsync() { var propertyNames = await EvaluateFunctionAsync(@"object => { - const enumerableProperties = []; - const descriptors = Object.getOwnPropertyDescriptors(object); - for (const propertyName in descriptors) { - if (descriptors[propertyName]?.enumerable) - { - enumerableProperties.push(propertyName); - } - } - return enumerableProperties; + return Object.keys(object ?? {}); }").ConfigureAwait(false); var dic = new Dictionary();