Skip to content
Snippets Groups Projects
Commit 167cc9ff authored by Tadej Novak's avatar Tadej Novak
Browse files

Merge branch 'aux.io.cxx20' into 'main'

use string::ends_with()

See merge request atlas/athena!75546
parents 87a9930e 557e6494
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,15 @@ namespace RootAuxDynIO
* @brief Check if a string ends with AUX_POSTFIX
* @param str the string to check
*/
bool endsWithAuxPostfix(std::string_view str);
inline bool endsWithAuxPostfix(std::string_view str) {
return str.ends_with(AUX_POSTFIX);
}
/**
* @brief if a string ends with AUX_POSTFIX then remove it
* @param str the string to modify
*/
bool removeAuxPostfix(std::string str);
/**
* @brief Construct branch name for a given dynamic attribute
......@@ -37,13 +45,17 @@ namespace RootAuxDynIO
} // namespace
/// check if a string ends with AUX_POSTFIX
inline bool
RootAuxDynIO::endsWithAuxPostfix(std::string_view str) {
return str.size() >= AUX_POSTFIX_LEN and
str.compare(str.size()-AUX_POSTFIX_LEN, AUX_POSTFIX_LEN, AUX_POSTFIX) == 0;
RootAuxDynIO::removeAuxPostfix(std::string str)
{
if( endsWithAuxPostfix(str) ) {
str.resize( str.size() - AUX_POSTFIX_LEN );
return true;
}
return false;
}
inline std::string
RootAuxDynIO::auxBranchName(const std::string& attr_name, const std::string& baseBranchName)
{
......
......@@ -49,7 +49,7 @@ namespace RootAuxDynIO
if( strncmp(brname, clname, namelen) == 0 && brname[namelen] == '_' ) {
key.erase (0, namelen+1);
}
if( endsWithAuxPostfix(key) ) key.erase( key.size()-AUX_POSTFIX_LEN );
removeAuxPostfix(key);
return key;
}
return "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment