Uploaded image for project: 'ClojureScript'
  1. CLJS-2950

Direct field access for keyword lookup on records

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Approval:
      Accepted
    • Patch:
      Code and Test

      Description

      If, via type inference, we know that a keyword is being used to lookup a field in a record, convert this to direct field access.

      Example:

      cljs.user=> (defrecord Foo [abcd efg])
      cljs.user/Foo
      cljs.user=> (def x (->Foo 1 2))
      #'cljs.user/x
      cljs.user=> (:abcd x)
      1
      cljs.user=> (set! *print-fn-bodies* true)
      true
      cljs.user=> (fn [] (:abcd x))
      #object[ret__8748__auto__ "function (){
      return cljs.user.x.abcd;
      }"]
      

        Attachments

          Activity

            People

            • Assignee:
              mfikes Mike Fikes
              Reporter:
              mfikes Mike Fikes
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: