Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1007766 // callFOpt_cached - optimized version of callFOpt [untested]

JavaX fragment (include)

1  
please include function callF.
2  
3  
static O callFOpt_cached(O f, O... args) ctex {
4  
  if (f == null) null;
5  
  if (f instanceof Runnable) { ((Runnable) f).run(); null; }
6  
  if (f instanceof S) ret callOptMC((S) f, args);
7  
  
8  
  Class c = f.getClass();
9  
  ArrayList<Method> methods;
10  
  synchronized(callF_cache) {
11  
    methods = callF_cache.get(c);
12  
    if (methods == null)
13  
      methods = callF_makeCache(c);
14  
  }
15  
  
16  
  int n = l(methods);
17  
  if (n == 0) null;
18  
  if (n == 1) ret methods.get(0).invoke(f, args);
19  
  for i to n: {
20  
    Method m = methods.get(i);
21  
    if (call_checkArgs(m, args, false))
22  
      ret m.invoke(f, args);
23  
  }
24  
  null;
25  
}

Author comment

Began life as a copy of #1007686

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007766
Snippet name: callFOpt_cached - optimized version of callFOpt [untested]
Eternal ID of this version: #1007766/1
Text MD5: 95693543d4482a46722830e1976daa92
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-05 11:25:10
Source code size: 649 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 542 / 566
Referenced in: [show references]