open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
55 stars 10 forks source link

Used early return to simplify the resolve_reference method from URI. #709

Closed khanrn closed 1 year ago

khanrn commented 2 years ago

When studying the codebase the current conditional structure of this resolve_reference function seemed a bit complex to me. Therefore, here I'm proposing new simplified conditional structure using early return.

NB. 100% of all the 26 tests has been passed! :slightly_smiling_face:

Selection_009

eidekrist commented 1 year ago

Do we need a test case which covers the changes in code?

restenb commented 1 year ago

I notice that the original implementation follows the canonical algorithm put forth by the RFC as seen here:

https://www.rfc-editor.org/rfc/rfc3986#section-5.2.2

Using the canonical algorithm at least gives me confidence that the conversion in the existing implementation was correct. So a test would be needed, but I don't know if I see the need to move away from the current implementation given that it's taken from the RFC.

khanrn commented 1 year ago

You are right @restenb. As the original one is an exact implementation from RFC 3986, therefore this shouldn't be refactored. :+1: