Skip to content

[FR]: Add ReadOnlySpan-based overload for FirebaseAnalytics.LogEvent #1013

Open
@abogarsukov-braingames

Description

@abogarsukov-braingames

Description

Currently there are overloads of the FirebaseAnalaytics.LogEvent for a single parameter and array of parameters. In most cases this is suboptimal as each event requires allocating an array of parameters. Adding an overload accepting ReadOnlySpan<Parameter> would help developers avoid unnecessary allocations.

API Proposal

Add a new LogEvent overload like this:

public unsafe static void LogEvent(string name, ReadOnlySpan<Parameter> parameters)
{
    IntPtr[] array = new IntPtr[parameters.Length];
    for (int i = 0; i < parameters.Length; i++)
    {
        array[i] = (IntPtr)Parameter.getCPtr(parameters[i]);
    }

    fixed (IntPtr* ptr = array)
    {
        FirebaseAnalyticsPINVOKE.LogEvent__SWIG_5(name, (IntPtr)ptr, parameters.Length);
        if (AppUtilPINVOKE.SWIGPendingException.Pending)
        {
            throw AppUtilPINVOKE.SWIGPendingException.Retrieve();
        }
    }
}

Firebase Product(s)

Analytics

Targeted Platform(s)

Apple Platforms, Android, Desktop

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions