Skip to content

FocusProvider.GetPointers<T> generates gargabe #8109

Description

@Alexees

Describe the bug

While profiling our application I found about 4 execution paths that all resulted in calling FocusProvider.GetPointers, which currently generates garbage every frame (1KB in our case)

public IEnumerable<T> GetPointers<T>() where T : class, IMixedRealityPointer
{
List<T> typePointers = new List<T>();
foreach (var pointer in pointers.Values)
{
T typePointer = pointer.Pointer as T;
if (typePointer != null)
{
typePointers.Add(typePointer);
}
}
return typePointers;
}

While this can be simplified in not creating a list everytime, is it possible or even required to get rid of gc altogether?

        public IEnumerable<T> GetPointers<T>() where T : class, IMixedRealityPointer
        {
            foreach (var pointer in pointers.Values)
            {
                T typePointer = pointer.Pointer as T;
                if (typePointer != null)
                {
                    yield return typePointer;
                }
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWon't FixA real bug, but Triage feels that the issue is not impactful enough to spend time on

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions