getTable(): Don't prepend slash if key already starts with it.

This makes getTable("/foo") and getTable("foo") equivalent.
This commit is contained in:
Peter Johnson
2016-01-14 21:38:04 -08:00
parent 9092b74f4e
commit c90a8c586f
3 changed files with 13 additions and 4 deletions

View File

@@ -82,12 +82,14 @@ const char* NetworkTable::LoadPersistent(
std::shared_ptr<NetworkTable> NetworkTable::GetTable(StringRef key) {
if (!s_running) Initialize();
llvm::SmallString<128> path;
if (!key.empty()) {
if (key.empty() || key[0] == PATH_SEPARATOR_CHAR) {
return std::make_shared<NetworkTable>(key, private_init());
} else {
llvm::SmallString<128> path;
path += PATH_SEPARATOR_CHAR;
path += key;
return std::make_shared<NetworkTable>(path, private_init());
}
return std::make_shared<NetworkTable>(path, private_init());
}
NetworkTable::NetworkTable(StringRef path, const private_init&)