summaryrefslogtreecommitdiffstats
path: root/src/ClashAvoider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClashAvoider.cpp')
-rw-r--r--src/ClashAvoider.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp
index 9c1d8f28..ed4dc91a 100644
--- a/src/ClashAvoider.cpp
+++ b/src/ClashAvoider.cpp
@@ -14,12 +14,12 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/ClashAvoider.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/ClashAvoider.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cctype>
@@ -62,7 +62,7 @@ ClashAvoider::map_path(const raul::Path& in)
// Path without _n suffix
std::string base_path_str = in;
if (has_offset) {
- base_path_str = base_path_str.substr(0, base_path_str.find_last_of('_'));
+ base_path_str.resize(base_path_str.find_last_of('_'));
}
raul::Path base_path(base_path_str);
@@ -98,12 +98,6 @@ ClashAvoider::map_path(const raul::Path& in)
auto o = _offsets.find(base_path);
if (o != _offsets.end()) {
offset = ++o->second;
- } else {
- std::string parent_str = in.parent().base();
- parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
- if (parent_str.empty()) {
- parent_str = "/";
- }
}
if (offset == 0) {
@@ -118,8 +112,8 @@ ClashAvoider::map_path(const raul::Path& in)
name = "_";
}
- raul::Symbol sym(name);
- std::string str = ss.str();
+ const raul::Symbol sym{name};
+ const std::string str{ss.str()};
auto i = _symbol_map.emplace(in, raul::Path(str));
@@ -158,13 +152,13 @@ numeric_suffix_start(const std::string& str)
}
std::string
-ClashAvoider::adjust_name(const raul::Path& old_path,
- const raul::Path& new_path,
- std::string name)
+ClashAvoider::adjust_name(const raul::Path& old_path,
+ const raul::Path& new_path,
+ const std::string& name)
{
const auto name_suffix_start = numeric_suffix_start(name);
if (!name_suffix_start) {
- return name; // No numeric suffix, just re-use old label
+ return name; // No numeric suffix, just reuse old label
}
const auto name_suffix = atoi(name.c_str() + *name_suffix_start);