فهرست منبع

Merge pull request #368 from alextomaili/fix-memory-allocation-overhead

allocate string for error description only if it really required
Tao Wen 6 سال پیش
والد
کامیت
94869abf43
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      reflect_struct_decoder.go

+ 1 - 1
reflect_struct_decoder.go

@@ -530,8 +530,8 @@ func (decoder *generalStructDecoder) decodeOneField(ptr unsafe.Pointer, iter *It
 		}
 	}
 	if fieldDecoder == nil {
-		msg := "found unknown field: " + field
 		if decoder.disallowUnknownFields {
+			msg := "found unknown field: " + field
 			iter.ReportError("ReadObject", msg)
 		}
 		c := iter.nextToken()