WordPress / WordPress/Requests

Performance improvement in Requests.php compatible_gzinflate() function

Open
#152 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
500
Avg merge
2d 21h
Merged PRs (30d)
5

Description

Regarding function: compatible_gzinflate()

LINES 834 to 838 read:

834    // Fallback for all above failing, not expected, but included for
835    // debugging and preventing regressions and to track stats
836    if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 2 ) ) ) ) {
837      return $decompressed;
838    }

However, the code at 836 to 838 may already have been attempted on Lines 797 to 799 in the event that $huffman encoded is TRUE.

796    if ( $huffman encoded ) {
797      if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 2 ) ) ) ) 
798        return $decompressed;
799    }

Accordingly the PERFORMANCE of Lines 834 to 838 can be improved by preceding Line 836 with an additional test:

new    if ( ! $huffman encoded) {
836      if ( false !== ( $decompressed = @gzinflate( substr( $gzData, 2 ) ) ) ) {
837        return $decompressed;
838      }
new    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Requests.php at the compatible_gzinflate() function and compare the fallback call around lines 834-838 with the earlier huffman-encoded branch around lines 796-799. Confirm that the fallback avoids repeating the same decompression attempt when it has already run, while preserving the existing fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
performance
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.