Commit 52a0b657 authored by JessonChan's avatar JessonChan

for better performance

parent f02ff042
...@@ -597,6 +597,9 @@ func formatLog(f interface{}, v ...interface{}) string { ...@@ -597,6 +597,9 @@ func formatLog(f interface{}, v ...interface{}) string {
switch f.(type) { switch f.(type) {
case string: case string:
msg = f.(string) msg = f.(string)
if len(v) == 0 {
return msg
}
if strings.Contains(msg, "%") && !strings.Contains(msg, "%%") { if strings.Contains(msg, "%") && !strings.Contains(msg, "%%") {
//format string //format string
} else { } else {
...@@ -604,7 +607,11 @@ func formatLog(f interface{}, v ...interface{}) string { ...@@ -604,7 +607,11 @@ func formatLog(f interface{}, v ...interface{}) string {
msg += strings.Repeat(" %v", len(v)) msg += strings.Repeat(" %v", len(v))
} }
default: default:
msg = fmt.Sprint(f) + strings.Repeat(" %v", len(v)) msg = fmt.Sprint(f)
if len(v) == 0 {
return msg
}
msg += strings.Repeat(" %v", len(v))
} }
return fmt.Sprintf(msg, v...) return fmt.Sprintf(msg, v...)
} }
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