Remove reflections: Misc and Summary#1137
Conversation
…into remove_reflection
This comment was marked as outdated.
This comment was marked as outdated.
|
btw comparsion of loading XSSF file. The performance is better for smaller files. And it looks like no obvious performance gains from removing Reflections alone.
Nuget: the nuget version. |
This comment was marked as outdated.
This comment was marked as outdated.
| public T Create() | ||
| { | ||
| return (T)Activator.CreateInstance(typeof(T)); | ||
| return new T(); |
There was a problem hiding this comment.
Although new T() uses Activator.CreateInstance internally, this semantic is slightly different for AOT analyzers I believe.
| { | ||
| return (OperandPtg)Clone(); | ||
| // REMOVE-REFLECTION: After careful inspection, MemberwiseClone() should be enough for all built-in OpreandPtgs. | ||
| return (OperandPtg)MemberwiseClone(); |
There was a problem hiding this comment.
All derived classes of OperandPtg holds only value types (some unused members are not, but that's fine).
| // private virtual object Clone() | ||
| //{ | ||
| //return this.Copy(); | ||
| //} |
There was a problem hiding this comment.
This is not used elsewhere. And IClonable.Clone throws NotImplementedException, see below.
|
I created a new branch called AOT. AOT branch will become a RC version for NPOI vNext. I'd like to compare the performance between AOT and non-AOT release. |
Thanks, I'm here if you want some help. |
try to fix #957
I found some upstream dependencies don't support AOT therefore NPOI cannot be completed AOTed. The library will get some performance improvement from removing reflections though.
@tonyqus What are your thoughts on this? These are the issues I've witnessed.
XWPFTableRow.CloneRowCT_*objects, henceNPOI.Util.ObjectExtensions.Copy<T>().rd.xmlor source generators for deepcopy. Perhaps it will just work.NPOI.OpenXml4Net.Util.XmlHelperXMLSerializerand enum names relies on reflections obviously.NPOI.DDF.DefaultEscherRecordFactoryNPOI.HSSF.Record.RecordFactoryNPOI.POIFS.Crypt.EncryptionInfoGetBuilderNPOI.XSSF.UserModel.XSSFFactoryCreateDocumentPartNPOI.XSSF.UserModel.XWPFFactoryCreateDocumentPartNPOI.HSSF.UserModel.OperationEvaluatorFactoryNPOI.POIFS.NIO.FileBackedDataSource.unmapNPOI.SS.Formula.Eval.Forked.ForkedEvaluator.CreateEvaluationWorkbookNPOI.OpenXml4Net.Util.ZipSecureFile.AddThresholdNPOI.Util.POILogFactory.GetLogger_loggerClassNameisNameof the type butType.GetTyperequiresFullName. It all ends up using the null logger.NPOI.SS.Formula.OperationEvaluatorFactory.AddPtg,OperandPtgIClonableis removed fromPtgbecause not used and requires deepcopy, except forOperandPtg. After inspection, all derived classes ofOperandPtgcontain only value-type members soMemberwiseCloneis enough. (besides,Ptg.IClonable.Clone()throwsNotImplementedExceptionso I doubt anyone is using it.)HSSFColor(T[])ArrayList.ToArray(typeof(T))NPOI.Util.SystemOutLogger&NPOI.Util.POILogFactoryProbably need to add
net8.0as another target since .NET 6 doesn't fully support AOT and AOT analyzers. But the Github CI/action don't support .NET 8.Generally there's no breaking change, except Remove reflections in POI Logger #1162