10000 Add: LinkBehaviour to AddTo by nuskey8 · Pull Request #106 · annulusgames/LitMotion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add: LinkBehaviour to AddTo #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2024
Merged

Add: LinkBehaviour to AddTo #106

merged 2 commits into from
Mar 17, 2024

Conversation

nuskey8
Copy link
Member
@nuskey8 nuskey8 commented Mar 17, 2024

No description provided.

@Akeit0
Copy link
Contributor
Akeit0 commented Mar 17, 2024

This seems good.
However, there is one improvement, it would be better if the initialization of the List is lazy.

struct LazyFastListCore<T>{
    public static int InitialCapacity=8;
    T[] array;
    int tailIndex;
    void AllocateIfNeeded(){
         if(array==null)array=new T[InitialCapacity];
    }

     public void Add(T element)
     {
         AllocateIfNeeded();
          if (array.Length == tailIndex)
          {
              Array.Resize(ref array, tailIndex * 2);
          }

          array[tailIndex] = element;
          tailIndex++;
      }

     public readonly Span<T> AsSpan() => array==null?default:array.AsSpan(0, tailIndex);
}

@nuskey8
Copy link
Member Author
nuskey8 commented Mar 17, 2024

Yes, I see that. If so, it would be better to delay the FastListCore array generation in the first place. Once this PR is merged, another PR will take care of it immediately.

@nuskey8 nuskey8 merged commit b222616 into main Mar 17, 2024
@nuskey8 nuskey8 deleted the feature-addto-behaviour branch March 17, 2024 10:24
@nuskey8
Copy link
Member Author
nuskey8 commented Mar 17, 2024

#107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0