Micro optimisations iterating through a tree in C#

前端 未结 3 875
情歌与酒
情歌与酒 2021-01-14 16:29

I\'m working on a massive number crunching project. I\'ve been optimising everything since the start as I knew it would be important. Doing performance anal

3条回答
  •  囚心锁ツ
    2021-01-14 17:22

    BranchNodeData looks like a reference type. its only 0.2% of your runtime because its just making a pointer to the data that already exists, not actually copying or assigning anything.

    You're probably getting such a hit on the null check because the CLR is having to do a cast in order to check the sealed class you've pasted in. Checking for nullity there isn't necessarily what you're after. There are a ton of ways to modify that class to give you a boolean to check against that wouldn't require as much computing power. I'd honestly go the route of having that be something that your ScTreeNode class can provide.

提交回复
热议问题