jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
368 stars 71 forks source link

Store prefix lenght to private property _prefixLenght #71

Closed KamilZm closed 3 years ago

KamilZm commented 3 years ago

GetPrefixLength() is very expensive method. If you call it many times (I have to +-1000000 calls), it will take a very long time. I store prefix lenght to private property _prefixLenght in order to optimise multiple calls GetPrefixLength().

Number of calls: 1000000 Without optimalisation 14635 ms With optimalisation: 4 ms

jsakamoto commented 3 years ago

@KamilZm Thank you for your contribution! 👍

I'll merge this pull request.

By the way, these changes are also safe for the case that rewriting the public setter properties of Begin and End?

see also: https://github.com/jsakamoto/ipaddressrange/issues/68

KamilZm commented 3 years ago

@jsakamoto Thank you, good point, you are right. I have fixed it.

PS: I'm sorry for my English

jsakamoto commented 3 years ago

@KamilZm Thank you for your effort!

I'll merge this pull request as soon as possible, and I'll publish a new version of this package. Thanks again!

P.S.

I'm sorry for my English

Don't mind! I'm also a not-native English speaker. 😄

jsakamoto commented 3 years ago

@KamilZm

I merged your pull request just now, and I published the new version of this package! 🎉

Again, thank you for your contribution! 👍