Skip to content

push @@inline attribute into cross module level #4607

@bobzhang

Description

@bobzhang

Following #4605, we can already benefit such code path:

let [@inline] forEachU a f =
  for i = 0 to Array.length a - 1 do 
    f (Array.unsafe_get a i) [@bs] 
  done
;; forEachU [|1;2;3|] (fun [@bs] x -> Js.log x)  

We should make sure that the cross module also works for such patterns in a conservative way to make it more meaningful.

Note this also works which is pretty cool, generating beautiful code:

let [@inline] forEach a f =
  for i = 0 to Array.length a - 1 do 
    f (Array.unsafe_get a i) 
  done


;; forEach [|1;2;3|] Js.log
var a = [
  1,
  2,
  3
];

for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){
  console.log(a[i]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions