Skip to content

minor optimization, use a hash table for dynamic type matches to make O(m*n) -> O(m+n) #748

Open
@glycerine

Description

@glycerine

I have tons of love for GopherJS. It is just a fantastic project. And it is making my efforts at a Go interpreter just fly.

Out of curiosity, I notice that the methodset matching uses the two loop O(m * n), algorithm to check for type assertion, for types with m and n count of methods[1]. So I thought I would suggest this small optimization. This match can be done in O(m + n) with a hash table; rsc mentions that the Go runtime does this. Its likely mostly likely a small improvement in the typical case, but could speed some programs up.

This might be a nice first issue for a new contributor. It is a fairly small and simple change, but the rationale is easy to understand.

[1]

for (var i = 0; i < interfaceMethods.length; i++) {

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