Search Unity

TextMesh Pro FastAction questions

Discussion in 'UGUI & TextMesh Pro' started by Peter77, Aug 22, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    TMP comes with various FastAction classes. The name suggests it's faster than using System.Action, but looking at the code, it uses System.Action internally.

    It seems FastAction is a layer on top of System.Action, but why?
    Do you have numbers how much faster it is?
    Is it safe to assume to use FastAction over Action always?
    Are there cases where using Action is more benefitial than using FastAction?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Those were implemented a long time ago as an alternative to using delegates which are immutable where using += operator generates allocations as the delegate list is recreated.

    Essentially it consists of replacing the raw delegates with wrapper classes that can handle registering to delegates and removal of them in constant time instead of linear time.

    This implementation was the contribution by a TMP user back then :)
     
    brian-nielsen and Peter77 like this.
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I see, thanks for the quick response!