mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-29 12:41:03 +00:00
Refactor mg_http_reply and mg_http_printf_chunk to use less allocs and mem copies
This commit is contained in:
1 parent
17e2fdd4cb
commit
bd7ee0d1e8
4 files changed
+55
-35
No files matched your search
@@ -31,10 +31,12 @@ void mg_log_set(int log_level) {
|
||||
|
||||
bool mg_log_prefix(int level, const char *file, int line, const char *fname) {
|
||||
if (level <= s_level) {
|
||||
const char *p = strrchr(file, MG_DIRSEP);
|
||||
const char *p = strrchr(file, '/');
|
||||
char buf[41];
|
||||
size_t n = mg_snprintf(buf, sizeof(buf), "%llx %d %s:%d:%s", mg_millis(),
|
||||
level, p == NULL ? fname : p + 1, line, fname);
|
||||
size_t n;
|
||||
if (p == NULL) p = strrchr(file, '\\');
|
||||
n = mg_snprintf(buf, sizeof(buf), "%llx %d %s:%d:%s", mg_millis(), level,
|
||||
p == NULL ? file : p + 1, line, fname);
|
||||
if (n > sizeof(buf) - 2) n = sizeof(buf) - 2;
|
||||
while (n < sizeof(buf)) buf[n++] = ' ';
|
||||
logs(buf, n - 1);
|
||||
|
||||
Reference in new issue
Block a user