cf7b871a94 (master): [ruby/uri] Improve performance of `URI::MailTo::EMAIL_REGEXP`

0 views
Skip to first unread message

Nobuyoshi Nakada

unread,
Jul 12, 2025, 6:33:03 AMJul 12
to ruby...@ruby-lang.org
Nobuyoshi Nakada 2025-07-12 10:31:31 +0000 (Sat, 12 Jul 2025)

New Revision: cf7b871a94

https://github.com/ruby/ruby/commit/cf7b871a94

Log:
[ruby/uri] Improve performance of `URI::MailTo::EMAIL_REGEXP`

Fix the performance regression at #172 for valid emails.

``` yml
prelude: |
require 'uri/mailto'
n = 1000
re = URI::MailTo::EMAIL_REGEXP
benchmark:
n.t..t.: re.match?("n.t..t.@docomo.ne.jp")
example: re.match?("exa...@example.info")
```

| |released| 788274b| c5974f0| this|
|:--------|-------:|-------:|-------:|-------:|
|n.t..t. | 3.795M| 4.864M| 4.993M| 8.739M|
| | -| 1.28x| 1.32x| 2.30x|
|example | 3.911M| 3.740M| 2.838M| 3.880M|
| | 1.38x| 1.32x| -| 1.37x|

https://github.com/ruby/uri/commit/7363a134ac

Modified files:
lib/uri/mailto.rb
test/uri/test_mailto.rb
Reply all
Reply to author
Forward
0 new messages