Skip to content

Commit 020dedf

Browse files
author
Marcin Radomski
committed
Reduce LOGGING_TAG_MAX_LEN, add comments
To use exactly 128-byte long stack allocated buffer.
1 parent 90f7f76 commit 020dedf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ impl AndroidLogger {
179179

180180
static ANDROID_LOGGER: OnceLock<AndroidLogger> = OnceLock::new();
181181

182-
const LOGGING_TAG_MAX_LEN: usize = 128;
182+
// Maximum length of a tag that does not require allocation.
183+
const LOGGING_TAG_MAX_LEN: usize = 127;
183184
const LOGGING_MSG_MAX_LEN: usize = 4000;
184185

185186
impl Default for AndroidLogger {
@@ -211,7 +212,7 @@ impl Log for AndroidLogger {
211212
return;
212213
}
213214

214-
// tag must not exceed LOGGING_TAG_MAX_LEN
215+
// tag longer than LOGGING_TAG_MAX_LEN causes allocation
215216
let mut tag_bytes: [MaybeUninit<u8>; LOGGING_TAG_MAX_LEN + 1] = uninit_array();
216217

217218
let module_path = record.module_path().unwrap_or_default().to_owned();

0 commit comments

Comments
 (0)