Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

super slow null check

Discussion in 'Scripting' started by januszbadziej1965, Nov 10, 2018.

  1. januszbadziej1965


    Mar 5, 2018
    hey, i am very disappointed with unity perfomance, but maybe it is my fault so i wanted to ask about my code.

    i am traversing a single linked list, and on every node i am checking for null.
    On low end pc it can take even 10ms with very large lists.

    here is my code:
    Code (CSharp):
    2.         while(n)
    3.         {
    4.           // do something
    5.            n;
    6.         }
    i know that unity has custom == operator or something, but does it mean that I can't do anything to speed it up? Maybe I should use List< > instead? But I am remvoing and adding often...
  2. GroZZleR


    Feb 1, 2015
    What's the "do something" part? That's most likely the cause of any performance issues. For confirmation, comment that part out and profile again.

    Also, how big is your LinkedList<>?
    Antypodish likes this.