Skip to content

Commit

Permalink
http/server/Send: use fmt::format_int instead of format_uint64()
Browse files Browse the repository at this point in the history
I suppose fmt is faster than my own clumsy code that uses memmove().
  • Loading branch information
MaxKellermann committed Jan 17, 2025
1 parent 72d0ba1 commit 5807792
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libcommon
6 changes: 3 additions & 3 deletions src/http/server/Send.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#include "http/Date.hxx"
#include "event/Loop.hxx"
#include "net/log/ContentType.hxx"
#include "util/DecimalFormat.hxx"
#include "util/SpanCast.hxx"
#include "product.h"

#include <fmt/format.h> // for fmt::format_int

#include <string.h>

using std::string_view_literals::operator""sv;
Expand Down Expand Up @@ -144,8 +145,7 @@ HttpServerConnection::SubmitResponse(HttpStatus status,
assert(content_length == 0);
} else if (got_body || !http_method_is_empty(request.request->method)) {
/* fixed body size */
format_uint64(response.content_length_buffer, content_length);
headers.Write("content-length", response.content_length_buffer);
headers.Write("content-length", fmt::format_int{content_length}.c_str());
}

const bool upgrade = body && http_is_upgrade(status, headers);
Expand Down

0 comments on commit 5807792

Please sign in to comment.