mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
ParsedS3URL::toHttpsUrl Slight optimize
I didn't want to block that PR on further code review while I figured out these new (to us) C++23 goodies.
This commit is contained in:
parent
fac34ad20f
commit
e4e8a615fa
1 changed files with 6 additions and 4 deletions
|
|
@ -68,8 +68,10 @@ try {
|
|||
|
||||
ParsedURL ParsedS3URL::toHttpsUrl() const
|
||||
{
|
||||
std::string regionStr = region.value_or("us-east-1");
|
||||
std::string schemeStr = scheme.value_or("https");
|
||||
auto toView = [](const auto & x) { return std::string_view{x}; };
|
||||
|
||||
auto regionStr = region.transform(toView).value_or("us-east-1");
|
||||
auto schemeStr = scheme.transform(toView).value_or("https");
|
||||
|
||||
// Handle endpoint configuration using std::visit
|
||||
return std::visit(
|
||||
|
|
@ -77,7 +79,7 @@ ParsedURL ParsedS3URL::toHttpsUrl() const
|
|||
[&](const std::monostate &) {
|
||||
// No custom endpoint, use standard AWS S3 endpoint
|
||||
return ParsedURL{
|
||||
.scheme = schemeStr,
|
||||
.scheme = std::string{schemeStr},
|
||||
.authority = ParsedURL::Authority{.host = "s3." + regionStr + ".amazonaws.com"},
|
||||
.path = (CanonPath::root / bucket / CanonPath(key)).abs(),
|
||||
};
|
||||
|
|
@ -85,7 +87,7 @@ ParsedURL ParsedS3URL::toHttpsUrl() const
|
|||
[&](const ParsedURL::Authority & auth) {
|
||||
// Endpoint is just an authority (hostname/port)
|
||||
return ParsedURL{
|
||||
.scheme = schemeStr,
|
||||
.scheme = std::string{schemeStr},
|
||||
.authority = auth,
|
||||
.path = (CanonPath::root / bucket / CanonPath(key)).abs(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue