seomoz / url-cpp

C++ bindings for url parsing and sanitization
MIT License
19 stars 11 forks source link

Add a `str()` method #5

Closed dlecocq closed 8 years ago

dlecocq commented 8 years ago

@b4hand @tanglyh @tammybailey @martin-seomoz

b4hand commented 8 years ago

LGTM, but I wonder if the trade off of recomputing toString() is a great one. The downside to keeping the fully formed URL is twice the space for the object.

dlecocq commented 8 years ago

I'm not sure what you mean -- are you suggesting we memoize the string representation?

b4hand commented 8 years ago

Yeah, that's what I was considering whether it was beneficial to store the full URL potentially in the constructor. Then the question is whether you eagerly store it or only on demand.

dlecocq commented 8 years ago

It's going to change when people start doing normalizations, so I figure it's best to do so lazily. Another use-case is to extract the PLD / TLD / FQDN, in which case str() would never even be invoked.