-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax Alfalfa Point ID Requirements #5296
Conversation
93af06f
to
912124c
Compare
bool AlfalfaPoint_Impl::isValidId(const std::string& id) { | ||
return !id.empty() && boost::regex_match(id, boost::regex(R"(^[A-Za-z0-9_\-\[\]:()]*$)")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TShapinsky can you clarify what you meant by "onerous"?
Was it just annoying / too restrictive?
Or was is slow?
Boost (and std) regexes are awful in terms of performance, but using a static regex makes it better (we use Meyers singletons in IddRegex.hpp for eg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was mostly annoying / too restrictive. For some background, the point ids become path parameters when interacting with the Alfalfa/BOPTest REST API. Originally I thought it would be neat to restrict the character set to avoid needing a lot of percent encoded characters. However, it's pretty common for names in open studio to include various different characters and since the requirement isn't hard I decided to get rid of it in the interest of making the alfalfa interface more user friendly.
src/alfalfa/AlfalfaPoint.cpp
Outdated
bool AlfalfaPoint_Impl::isValidId(const std::string& id) { | ||
return !id.empty() && boost::regex_match(id, boost::regex(R"(^[A-Za-z0-9_\-\[\]:()]*$)")); | ||
} | ||
|
||
std::string AlfalfaPoint_Impl::toIdString(const std::string& str) { | ||
return boost::regex_replace(str, boost::regex(" "), "_"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a side note, but this is probably much faster, not that it matters much probably
#include <algorithm>
std::replace( str.begin(), str.end(), ' ', '_')
Edit: It is in fact, 150 times faster: https://quick-bench.com/q/LBF5Z_hhF14xxmjJ8IGs7UhGAUY
Co-authored-by: Julien Marrec <julien.marrec@gmail.com>
Co-authored-by: Julien Marrec <julien.marrec@gmail.com>
CI Results for d5c11a6:
|
@kbenne can you merge it? I don't have permission to do so. |
Pull request overview
After testing the new interface in the real world I found the requirements on id characters to be too onerous. This PR removes all requirements outside of non emptiness.
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.