Explorar el Código

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

allocate string for error description only if it really required
Tao Wen hace 6 años
padre
commit
94869abf43
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  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()