Skip to content

parsedate: find names and months faster - #22981

Closed
bagder wants to merge 4 commits into
masterfrom
bagder/datename-scans
Closed

bagder wants to merge 4 commits into
masterfrom
bagder/datename-scans

Conversation

@bagder

@bagder bagder commented Sep 17, 2026

Copy link
Copy Markdown
Member

Implements faster lookups for which specific week name and month name that is provided; without loops.

With this applied, the dateparser perf test completes almost twice as fast for me.

@testclutch

This comment was marked as resolved.

@github-actions github-actions Bot added the tests label Sep 17, 2026
@bagder
bagder requested a balanced review from Copilot September 17, 2026 10:45
@bagder
bagder marked this pull request as ready for review September 17, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new lookup logic accepts malformed weekday and month names.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Optimizes HTTP date parsing by replacing weekday and month lookup loops with direct character dispatch.

Changes:

  • Adds constant-time weekday and month matching.
  • Adds coverage for an alternate date-field ordering.
File summaries
File Description
lib/parsedate.c Implements direct name lookups.
tests/libtest/lib517.c Adds a date parsing case.
Review details

Suppressed comments (4)

lib/parsedate.c:268

  • The equality test is passed into LOWERCASE, making this operand always nonzero. Consequently, any three-letter token starting with Fe is incorrectly accepted as February.
    if((LOWERCASE(check[1]) == 'e') && LOWERCASE(check[2] == 'b'))

lib/parsedate.c:292

  • The equality test is passed into LOWERCASE, making this operand always nonzero. Consequently, any three-letter token starting with No is incorrectly accepted as November.
    if((LOWERCASE(check[1]) == 'o') && LOWERCASE(check[2] == 'v'))

lib/parsedate.c:296

  • The equality test is passed into LOWERCASE, making this operand always nonzero. Consequently, any three-letter token starting with Oc is incorrectly accepted as October.
    if((LOWERCASE(check[1]) == 'c') && LOWERCASE(check[2] == 't'))

lib/parsedate.c:300

  • The equality test is passed into LOWERCASE, making this operand always nonzero. Consequently, any three-letter token starting with Se is incorrectly accepted as September.
    if((LOWERCASE(check[1]) == 'e') && LOWERCASE(check[2] == 'p'))
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/parsedate.c Outdated
Comment thread lib/parsedate.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new unit test causes link failures when date parsing is disabled.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tests/unit/unit4781.c
Comment thread lib/parsedate.c Outdated
Implements faster lookups for which specific week name and month name
that is provided; without loops.

With this applied, the dateparser perf test completes almost twice as
fast for me.

Add unit test 4781 to verify each parser.
@bagder
bagder force-pushed the bagder/datename-scans branch from 7ca06ff to c20b20a Compare September 17, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The optimized lookups preserve existing mappings and are covered by focused unit and integration tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@bagder bagder closed this in e7f76c7 Sep 17, 2026
@bagder
bagder deleted the bagder/datename-scans branch September 17, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants