Unverified Commit 5876248b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

perf: use length = 0 to clear the logging array (#88244)

parent d1f8a3bc
......@@ -89,7 +89,7 @@ export class FileLogger {
// Only flush to disk if mcpServer is enabled
if (!this.mcpServerEnabled) {
this.logQueue = [] // Clear the queue without writing
this.logQueue.length = 0 // Clear the queue without GC overhead
this.flushTimer = null
return
}
......@@ -104,7 +104,7 @@ export class FileLogger {
const logsToWrite = this.logQueue.join('')
// Writing logs to files synchronously to ensure they're written before returning
fs.appendFileSync(this.logFilePath, logsToWrite)
this.logQueue = []
this.logQueue.length = 0 // Clear the queue without GC overhead
} catch (error) {
console.error('Failed to flush logs to file:', error)
} finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment