Skip to content

Make non-public API methods static where applicable#1531

Merged
tonyqus merged 1 commit into
nissl-lab:masterfrom
lahma:static-methods
Mar 31, 2025
Merged

Make non-public API methods static where applicable#1531
tonyqus merged 1 commit into
nissl-lab:masterfrom
lahma:static-methods

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 30, 2025

Some empty methods were removed as they were not used and not part of public API.

@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Mar 30, 2025

What's the advantage of converting non-static methods to static? faster?

@tonyqus tonyqus added this to the NPOI 2.7.4 milestone Mar 30, 2025
@lahma
Copy link
Copy Markdown
Collaborator Author

lahma commented Mar 31, 2025

The CA1822 rule description has pretty good explanation:

Members that do not access instance data or call instance methods can be marked as static (Shared in Visual Basic). After you mark the methods as static, the compiler will emit nonvirtual call sites to these members. Emitting nonvirtual call sites will prevent a check at run time for each call that makes sure that the current object pointer is non-null. This can achieve a measurable performance gain for performance-sensitive code. In some cases, the failure to access the current object instance represents a correctness issue.

@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Mar 31, 2025

LGTM

@tonyqus tonyqus merged commit 061a61a into nissl-lab:master Mar 31, 2025
@lahma lahma deleted the static-methods branch March 31, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants