1
0
mirror of https://github.com/armink/EasyLogger.git synced 2025-01-31 13:32:52 +08:00

提高buf为空时的elog_flush() 性能 (#81)

* 先判断buf中是否有数据,再进行上锁-输出-解锁的操作,避免buf为空时的频繁上/解锁操作
This commit is contained in:
book诗意 2021-03-11 11:12:03 +08:00 committed by GitHub
parent fd21dfe753
commit e442625088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,8 @@ void elog_buf_output(const char *log, size_t size) {
* flush all buffered logs to output device
*/
void elog_flush(void) {
if (buf_write_size == 0)
return;
/* lock output */
elog_output_lock();
/* output log */