donatj / PhpUserAgent

Lightning Fast, Minimalist PHP User Agent String Parser.
https://donatstudios.com/PHP-Parser-HTTP_USER_AGENT
MIT License
565 stars 128 forks source link

use strict type compares #77

Closed Rotzbua closed 2 years ago

Rotzbua commented 2 years ago

to improve security and code quality

donatj commented 2 years ago

This is a duplicate of #46

I'm not interested at this time.

Strict checks are slightly slower - and one the stated goal of this library is to be as fast as possible. Beyond that, these specific checks being strict doesn't actually prevent any real world problems in this library.

Using an updated benchmark from #46

benchmark code ```php $expected_result) { $result = parse_user_agent($ua); } } echo "\n"; echo microtime(true) - $time; echo "\n"; ```

image

Rotzbua commented 2 years ago

Ok. Which version did you used? With php 8.0 I could not observe a real performance impact. The variance was about 1% which was about the same as between equal runs.


Master:
21.806071043015
21.833745002747
22.004218816757

PR:
21.754186153412
21.871387004852
21.807912826538