Skip to content

Optimize Decoder: Replace string concatenation loops with array/implode - #13

Closed
adapik wants to merge 1 commit into
masterfrom
claude/parsing-performance-review-xi8ucs
Closed

Optimize Decoder: Replace string concatenation loops with array/implode#13
adapik wants to merge 1 commit into
masterfrom
claude/parsing-performance-review-xi8ucs

Conversation

@adapik

@adapik adapik commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Replace inefficient string concatenation in loops with array append and implode pattern. This changes O(n²) string operations to O(n).

  • In parseBinaryIdentifier(): collect identifier octets in array then implode once instead of concatenating in loop
  • In parseContentLength(): collect length octets in array then implode once instead of concatenating in loop

This optimization is especially beneficial when parsing long-form identifiers and content lengths, which are common in X.509 and complex ASN.1 structures.

Replace inefficient string concatenation in loops with array append
and implode pattern. This changes O(n²) string operations to O(n).

- In parseBinaryIdentifier(): collect identifier octets in array
  then implode once instead of concatenating in loop
- In parseContentLength(): collect length octets in array then
  implode once instead of concatenating in loop

This optimization is especially beneficial when parsing long-form
identifiers and content lengths, which are common in X.509 and
complex ASN.1 structures.
@adapik adapik closed this Jul 25, 2026
@adapik
adapik deleted the claude/parsing-performance-review-xi8ucs branch July 25, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant