redmica / redmine_ip_filter

3 stars 3 forks source link

Improve the performance of FilterRule#valid_access? #8

Closed vividtone closed 4 years ago

vividtone commented 4 years ago

This patch improves the performance of FilterRule#valid_access? by reducing the number of expensive IPAddr.new calls.

Currently, valid_access? calls IPAddr.new as many times as the number of allowed IP addresses. This improved code stops calling IPAddr.new when an allowed IP address matches remote_ip.

takenory commented 4 years ago

Thank you for your improvement! The proposed code seems to be more cost effective for IPAdder.new. I have confirmed that all the tests pass and will merge.