Skip to content

Commit

Permalink
bp/FileHandler: use ConcatView() where std::string_view is enough
Browse files Browse the repository at this point in the history
This eliminates unnecessary strlen() calls.
  • Loading branch information
MaxKellermann committed Jan 31, 2025
1 parent 37b5af2 commit f5b0bb0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/bp/FileHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ Request::HandleFileAddressAfterBase(FileDescriptor base, std::string_view strip_
{
const FileAddress &address = *handler.file.address;

const char *path = address.base != nullptr
? AllocatorPtr{pool}.Concat(address.base, address.path)
: address.path;
std::string_view path{address.path};
if (address.base != nullptr)
path = AllocatorPtr{pool}.ConcatView(address.base, path);

static constexpr struct open_how open_read_only{
.flags = O_RDONLY|O_NOCTTY|O_CLOEXEC|O_NONBLOCK,
Expand Down Expand Up @@ -548,9 +548,9 @@ Request::StatFileAddressAfterBase(FileDescriptor base, std::string_view strip_ba

const FileAddress &address = *handler.file.address;

const char *path = address.base != nullptr
? AllocatorPtr{pool}.Concat(address.base, address.path)
: address.path;
std::string_view path{address.path};
if (address.base != nullptr)
path = AllocatorPtr{pool}.ConcatView(address.base, path);

static constexpr struct open_how open_read_only{
.flags = O_RDONLY|O_NOCTTY|O_CLOEXEC|O_NONBLOCK,
Expand Down

0 comments on commit f5b0bb0

Please sign in to comment.