0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd: Various string_view conversion fixes.

This commit is contained in:
Jason Volk 2018-09-13 05:43:30 -07:00
parent 6c629d3d89
commit 81d7ba8c39
3 changed files with 32 additions and 7 deletions

View file

@ -47,6 +47,19 @@ struct ircd::string_view
return !empty();
}
/// CAREFUL. THIS IS ON PURPOSE. By relaxing this conversion we're reducing
/// the amount of explicit std::string() pollution when calling out to code
/// which doesn't support string_view *yet* (keyword: yet). When it does
/// support string_view then this conversion won't happen, and we don't
/// have to change anything in our code. The price here is that an
/// occasional regression analysis on where these conversions are occurring
/// should be periodically performed to make sure there are no unwanted
/// silent accidents.
operator std::string() const
{
return std::string(cbegin(), cend());
}
/// (non-standard) When data() != nullptr we consider the string defined
/// downstream in this project wrt JS/JSON. This is the bit of information
/// we're deciding on for defined|undefined. If this string_view is
@ -169,7 +182,7 @@ struct ircd::string_view
// :std::string_view{start, size}
// {}
explicit string_view(const std::string &string)
string_view(const std::string &string)
:std::string_view{string.data(), string.size()}
{}

View file

@ -223,11 +223,16 @@ void
ircd::db::init_test_direct_io()
try
{
if(fs::direct_io_support(direct_io_test_file_path()))
const auto test_file_path
{
direct_io_test_file_path()
};
if(fs::direct_io_support(test_file_path))
log::debug
{
log, "Detected Direct-IO works by opening test file at `%s'",
direct_io_test_file_path()
test_file_path
};
else
log::warning
@ -256,7 +261,12 @@ ircd::db::direct_io_test_file_path()
fs::get(fs::DB)
};
return fs::make_path({dbdir, "SUPPORTS_DIRECT_IO"s});
const std::string parts[]
{
dbdir, "SUPPORTS_DIRECT_IO"s
};
return fs::make_path(parts);
}
void
@ -8792,10 +8802,12 @@ ircd::db::path(const string_view &name,
fs::get(fs::DB)
};
return fs::make_path(
const string_view parts[]
{
prefix, name, lex_cast(checkpoint)
});
};
return fs::make_path(parts);
}
std::pair<ircd::string_view, uint64_t>

View file

@ -291,7 +291,7 @@ try
ret->header->version,
!ret->description().empty()?
ret->description():
"<no description>"s
"<no description>"_sv
};
return ret;