Преглед на файлове

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()