forked from qt-creator/qt-creator
Utils: Remove std::initializer_list contructor
If you write
Utils::SmallStringView view;
Utils::SmallString text{view};
it selects the std::initializer_list contructor. Not the didicated
constructore. It is much to easy to get it wrong so it is better
to make it explicit.
Change-Id: I4240eaf1f39cf71d37df4480fea1ecfa3ea83cb0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -219,7 +219,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const CompilerMacro ¯o : macros)
|
for (const CompilerMacro ¯o : macros)
|
||||||
commandLine.emplace_back(Utils::SmallString{"-D", macro.key, "=", macro.value});
|
commandLine.emplace_back(Utils::SmallString::join({"-D", macro.key, "=", macro.value}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPreIncludeSearchPath(NativeFilePathView preIncludeSearchPath)
|
void addPreIncludeSearchPath(NativeFilePathView preIncludeSearchPath)
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
FilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
FilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
||||||
: Utils::PathString({directory, "/", name}),
|
: Utils::PathString(Utils::PathString::join({directory, "/", name}))
|
||||||
m_slashIndex(std::ptrdiff_t(directory.size()))
|
, m_slashIndex(std::ptrdiff_t(directory.size()))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool isValid() const { return size() > 0 && m_slashIndex >= 0; }
|
bool isValid() const { return size() > 0 && m_slashIndex >= 0; }
|
||||||
|
|||||||
@@ -83,8 +83,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
NativeFilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
NativeFilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
||||||
: m_path({directory, Utils::HostOsInfo::isWindowsHost() ? "\\" : "/", name}),
|
: m_path(Utils::PathString::join(
|
||||||
m_slashIndex(directory.size())
|
{directory, Utils::HostOsInfo::isWindowsHost() ? "\\" : "/", name}))
|
||||||
|
, m_slashIndex(directory.size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Utils::SmallStringView directory() const noexcept
|
Utils::SmallStringView directory() const noexcept
|
||||||
|
|||||||
@@ -248,9 +248,8 @@ void CreateTableSqlStatementBuilder::bindColumnDefinitionsAndTableConstraints()
|
|||||||
columnDefinitionStrings.reserve(m_columns.size());
|
columnDefinitionStrings.reserve(m_columns.size());
|
||||||
|
|
||||||
for (const Column &column : m_columns) {
|
for (const Column &column : m_columns) {
|
||||||
Utils::SmallString columnDefinitionString = {column.name,
|
auto columnDefinitionString = Utils::SmallString::join(
|
||||||
SqlStatementBuilder::columnTypeToString(
|
{column.name, SqlStatementBuilder::columnTypeToString(column.type)});
|
||||||
column.type)};
|
|
||||||
|
|
||||||
ContraintsVisiter visiter{columnDefinitionString};
|
ContraintsVisiter visiter{columnDefinitionString};
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ sqlite3 *DatabaseBackend::sqliteDatabaseHandle() const
|
|||||||
|
|
||||||
void DatabaseBackend::setPragmaValue(Utils::SmallStringView pragmaKey, Utils::SmallStringView newPragmaValue)
|
void DatabaseBackend::setPragmaValue(Utils::SmallStringView pragmaKey, Utils::SmallStringView newPragmaValue)
|
||||||
{
|
{
|
||||||
ReadWriteStatement<1>{Utils::SmallString{"PRAGMA ", pragmaKey, "='", newPragmaValue, "'"},
|
ReadWriteStatement<1>{Utils::SmallString::join({"PRAGMA ", pragmaKey, "='", newPragmaValue, "'"}),
|
||||||
m_database}
|
m_database}
|
||||||
.execute();
|
.execute();
|
||||||
Utils::SmallString pragmeValueInDatabase = toValue<Utils::SmallString>("PRAGMA " + pragmaKey);
|
Utils::SmallString pragmeValueInDatabase = toValue<Utils::SmallString>("PRAGMA " + pragmaKey);
|
||||||
|
|||||||
@@ -57,18 +57,17 @@ public:
|
|||||||
checkTableName();
|
checkTableName();
|
||||||
checkColumns();
|
checkColumns();
|
||||||
|
|
||||||
return {"CREATE ",
|
return Utils::SmallString::join({"CREATE ",
|
||||||
m_indexType == IndexType::Unique ? "UNIQUE " : "",
|
m_indexType == IndexType::Unique ? "UNIQUE " : "",
|
||||||
"INDEX IF NOT EXISTS index_",
|
"INDEX IF NOT EXISTS index_",
|
||||||
m_tableName,
|
m_tableName,
|
||||||
"_",
|
"_",
|
||||||
m_columnNames.join("_"),
|
m_columnNames.join("_"),
|
||||||
" ON ",
|
" ON ",
|
||||||
m_tableName,
|
m_tableName,
|
||||||
"(",
|
"(",
|
||||||
m_columnNames.join(", "),
|
m_columnNames.join(", "),
|
||||||
")"
|
")"});
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkTableName() const
|
void checkTableName() const
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ void Internal::SessionsBase::createSessionTable(Database &database)
|
|||||||
|
|
||||||
void Sessions::revert()
|
void Sessions::revert()
|
||||||
{
|
{
|
||||||
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
|
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
|
||||||
sessionsTableName,
|
sessionsTableName,
|
||||||
" ORDER BY id DESC"},
|
" ORDER BY id DESC"}),
|
||||||
database};
|
database};
|
||||||
|
|
||||||
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
|
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
|
||||||
@@ -151,9 +151,9 @@ void Sessions::revert()
|
|||||||
|
|
||||||
void Sessions::apply()
|
void Sessions::apply()
|
||||||
{
|
{
|
||||||
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
|
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
|
||||||
sessionsTableName,
|
sessionsTableName,
|
||||||
" ORDER BY id"},
|
" ORDER BY id"}),
|
||||||
database};
|
database};
|
||||||
|
|
||||||
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
|
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
|
||||||
@@ -182,14 +182,14 @@ void Sessions::applyAndUpdateSessions()
|
|||||||
|
|
||||||
void Sessions::deleteAll()
|
void Sessions::deleteAll()
|
||||||
{
|
{
|
||||||
WriteStatement{Utils::SmallString{"DELETE FROM ", sessionsTableName}, database}.execute();
|
WriteStatement{Utils::SmallString::join({"DELETE FROM ", sessionsTableName}), database}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionChangeSets Sessions::changeSets() const
|
SessionChangeSets Sessions::changeSets() const
|
||||||
{
|
{
|
||||||
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
|
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
|
||||||
sessionsTableName,
|
sessionsTableName,
|
||||||
" ORDER BY id DESC"},
|
" ORDER BY id DESC"}),
|
||||||
database};
|
database};
|
||||||
|
|
||||||
return selectChangeSets.values<SessionChangeSet>(1024);
|
return selectChangeSets.values<SessionChangeSet>(1024);
|
||||||
|
|||||||
@@ -62,9 +62,8 @@ public:
|
|||||||
Utils::SmallStringView sessionsTableName)
|
Utils::SmallStringView sessionsTableName)
|
||||||
: SessionsBase(database, sessionsTableName)
|
: SessionsBase(database, sessionsTableName)
|
||||||
, database(database)
|
, database(database)
|
||||||
, insertSession{Utils::PathString{"INSERT INTO ",
|
, insertSession{Utils::PathString::join(
|
||||||
sessionsTableName,
|
{"INSERT INTO ", sessionsTableName, "(changeset) VALUES(?)"}),
|
||||||
"(changeset) VALUES(?)"},
|
|
||||||
database}
|
database}
|
||||||
, databaseName(databaseName)
|
, databaseName(databaseName)
|
||||||
, session{nullptr, sqlite3session_delete}
|
, session{nullptr, sqlite3session_delete}
|
||||||
|
|||||||
@@ -152,14 +152,7 @@ public:
|
|||||||
>
|
>
|
||||||
BasicSmallString(BeginIterator begin, EndIterator end)
|
BasicSmallString(BeginIterator begin, EndIterator end)
|
||||||
: BasicSmallString(&(*begin), size_type(end - begin))
|
: BasicSmallString(&(*begin), size_type(end - begin))
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
BasicSmallString(std::initializer_list<SmallStringView> list)
|
|
||||||
: m_data(Internal::StringDataLayout<Size>())
|
|
||||||
{
|
|
||||||
appendInitializerList(list, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
~BasicSmallString() noexcept
|
~BasicSmallString() noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ void AsynchronousImageCache::request(Utils::SmallStringView name,
|
|||||||
ImageCacheGeneratorInterface &generator,
|
ImageCacheGeneratorInterface &generator,
|
||||||
TimeStampProviderInterface &timeStampProvider)
|
TimeStampProviderInterface &timeStampProvider)
|
||||||
{
|
{
|
||||||
const auto id = extraId.empty() ? Utils::PathString{name} : Utils::PathString{name, "+", extraId};
|
const auto id = extraId.empty() ? Utils::PathString{name}
|
||||||
|
: Utils::PathString::join({name, "+", extraId});
|
||||||
|
|
||||||
const auto timeStamp = timeStampProvider.timeStamp(name);
|
const auto timeStamp = timeStampProvider.timeStamp(name);
|
||||||
const auto entry = requestType == RequestType::Image ? storage.fetchImage(id, timeStamp)
|
const auto entry = requestType == RequestType::Image ? storage.fetchImage(id, timeStamp)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void ImageCacheGenerator::generateImage(Utils::SmallStringView name,
|
|||||||
namespace {
|
namespace {
|
||||||
Utils::PathString createId(Utils::SmallStringView name, Utils::SmallStringView extraId)
|
Utils::PathString createId(Utils::SmallStringView name, Utils::SmallStringView extraId)
|
||||||
{
|
{
|
||||||
return extraId.empty() ? Utils::PathString{name} : Utils::PathString{name, "+", extraId};
|
return extraId.empty() ? Utils::PathString{name} : Utils::PathString::join({name, "+", extraId});
|
||||||
}
|
}
|
||||||
template<typename Callbacks, typename... Argument>
|
template<typename Callbacks, typename... Argument>
|
||||||
void callCallbacks(const Callbacks &callbacks, Argument &&...arguments)
|
void callCallbacks(const Callbacks &callbacks, Argument &&...arguments)
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ namespace {
|
|||||||
|
|
||||||
Utils::PathString createId(Utils::PathString filePath, Utils::SmallString extraId)
|
Utils::PathString createId(Utils::PathString filePath, Utils::SmallString extraId)
|
||||||
{
|
{
|
||||||
return extraId.empty() ? Utils::PathString{filePath} : Utils::PathString{filePath, "+", extraId};
|
return extraId.empty() ? Utils::PathString{filePath}
|
||||||
|
: Utils::PathString::join({filePath, "+", extraId});
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SourcePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
SourcePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
||||||
: Utils::PathString({directory, "/", name})
|
: Utils::PathString(Utils::PathString::join({directory, "/", name}))
|
||||||
, m_slashIndex(std::ptrdiff_t(directory.size()))
|
, m_slashIndex(std::ptrdiff_t(directory.size()))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -92,10 +92,12 @@ FilePath PchCreator::generatePchFilePath() const
|
|||||||
std::uniform_int_distribution<std::uint_fast64_t> distribution(
|
std::uniform_int_distribution<std::uint_fast64_t> distribution(
|
||||||
1, std::numeric_limits<std::uint_fast64_t>::max());
|
1, std::numeric_limits<std::uint_fast64_t>::max());
|
||||||
|
|
||||||
return FilePathView{Utils::PathString{Utils::SmallString(m_environment.pchBuildDirectory()),
|
auto joinedPath = Utils::PathString::join({Utils::SmallString(m_environment.pchBuildDirectory()),
|
||||||
"/",
|
"/",
|
||||||
std::to_string(distribution(randomNumberGenator)),
|
std::to_string(distribution(randomNumberGenator)),
|
||||||
".pch"}};
|
".pch"});
|
||||||
|
|
||||||
|
return FilePathView{joinedPath};
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::SmallStringVector PchCreator::generateClangCompilerArguments(const PchTask &pchTask,
|
Utils::SmallStringVector PchCreator::generateClangCompilerArguments(const PchTask &pchTask,
|
||||||
|
|||||||
@@ -1556,7 +1556,7 @@ TEST(SmallString, CompareTextWithDifferentLineEndings)
|
|||||||
|
|
||||||
TEST(SmallString, ConstSubscriptOperator)
|
TEST(SmallString, ConstSubscriptOperator)
|
||||||
{
|
{
|
||||||
const SmallString text = {"some text"};
|
const SmallString text{"some text"};
|
||||||
|
|
||||||
auto &&sign = text[5];
|
auto &&sign = text[5];
|
||||||
|
|
||||||
@@ -1565,7 +1565,7 @@ TEST(SmallString, ConstSubscriptOperator)
|
|||||||
|
|
||||||
TEST(SmallString, NonConstSubscriptOperator)
|
TEST(SmallString, NonConstSubscriptOperator)
|
||||||
{
|
{
|
||||||
SmallString text = {"some text"};
|
SmallString text{"some text"};
|
||||||
|
|
||||||
auto &&sign = text[5];
|
auto &&sign = text[5];
|
||||||
|
|
||||||
@@ -1574,7 +1574,7 @@ TEST(SmallString, NonConstSubscriptOperator)
|
|||||||
|
|
||||||
TEST(SmallString, ManipulateConstSubscriptOperator)
|
TEST(SmallString, ManipulateConstSubscriptOperator)
|
||||||
{
|
{
|
||||||
const SmallString text = {"some text"};
|
const SmallString text{"some text"};
|
||||||
auto &&sign = text[5];
|
auto &&sign = text[5];
|
||||||
|
|
||||||
sign = 'q';
|
sign = 'q';
|
||||||
@@ -1609,28 +1609,28 @@ TEST(SmallString, EmptyInitializerListSize)
|
|||||||
|
|
||||||
TEST(SmallString, EmptyInitializerListNullTerminated)
|
TEST(SmallString, EmptyInitializerListNullTerminated)
|
||||||
{
|
{
|
||||||
auto end = SmallString{{}}[0];
|
auto end = SmallString::join({})[0];
|
||||||
|
|
||||||
ASSERT_THAT(end, '\0');
|
ASSERT_THAT(end, '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SmallString, InitializerListContent)
|
TEST(SmallString, InitializerListContent)
|
||||||
{
|
{
|
||||||
SmallString text = {"some", " ", "text"};
|
auto text = SmallString::join({"some", " ", "text"});
|
||||||
|
|
||||||
ASSERT_THAT(text, SmallString("some text"));
|
ASSERT_THAT(text, SmallString("some text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SmallString, InitializerListSize)
|
TEST(SmallString, InitializerListSize)
|
||||||
{
|
{
|
||||||
SmallString text = {"some", " ", "text"};
|
auto text = SmallString::join({"some", " ", "text"});
|
||||||
|
|
||||||
ASSERT_THAT(text, SizeIs(9));
|
ASSERT_THAT(text, SizeIs(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SmallString, InitializerListNullTerminated)
|
TEST(SmallString, InitializerListNullTerminated)
|
||||||
{
|
{
|
||||||
auto end = SmallString{"some", " ", "text"}[9];
|
auto end = SmallString::join({"some", " ", "text"})[9];
|
||||||
|
|
||||||
ASSERT_THAT(end, '\0');
|
ASSERT_THAT(end, '\0');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user