SyslogNet icon indicating copy to clipboard operation
SyslogNet copied to clipboard

Removing unnecessary copy on serialization

Open rwkarg opened this issue 8 years ago • 0 comments

SyslogMessage.StructuredDataElement is accepted as an array but was being stored and surfaced through the get property as an IEnumerable<>. This required a .ToList() on every serialization request as well as a .Any().

Changing the backing field and get property to an array removes the copy from the .ToList() and allows a .Length != 0 instead of the Linq .Any().

It is mostly a non-breaking change as any usage of the SyslogMessage.StructuredDataElement assuming an IEnumerable<> will work against the new array type. Inspection of the actual type returned will continue to be an array as before. The only potential for a breaking change would be code that depends on the defined type of the property (not the type of what's returned) being an IEnumerable<> but that seems like an odd requirement for code to depend on and is easily updated by changing the expected type.

rwkarg avatar Jul 18 '17 16:07 rwkarg