Clojure

[Patch] Allow for type-hinting the method receiver in memfn

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Patch:
    Code
  • Approval:
    Ok

Description

The attached patch copies metadata given to the method name symbol of memfn to the method receiver in the expansion. That way, memfn is able to be used even for type-hinted calls resulting in a big performance win.

user> (time (dotimes [i 1000000] ((memfn intValue) 1)))
Reflection warning, NO_SOURCE_FILE:1 - call to intValue can't be resolved.
"Elapsed time: 2579.229115 msecs"
nil
user> (time (dotimes [i 1000000] ((memfn ^Number intValue) 1)))
"Elapsed time: 12.015235 msecs"
nil

Activity

Hide
Aaron Bedra added a comment -

Applies properly against d4170e65d001c8c2976f1bd7159484056b9a9d6d. Things look good to me.

Show
Aaron Bedra added a comment - Applies properly against d4170e65d001c8c2976f1bd7159484056b9a9d6d. Things look good to me.
Hide
Tassilo Horn added a comment -

Updated patch.

Show
Tassilo Horn added a comment - Updated patch.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: