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

23
LINES

< > BotCompany Repo | #1018167 // preciseCallOpt - better method resolution. Could optimize method lookup

JavaX fragment (include)

1  
sbool preciseCall_debug;
2  
3  
static O preciseCallOpt(Object o, String method, Object... args) ctex {
4  
  if (o instanceof Class) {
5  
    _MethodCache cache = callOpt_getCache(o);
6  
    L<Method> methods = cache.cache.get(method);
7  
    //L<Method> methods = findMethodsNamed2(o, method, true);
8  
    new Lowest<Method> best;
9  
    if (methods != null) for (Method m : methods) {
10  
      int score = methodApplicabilityScore(m, args);
11  
      if (score < Int.MAX_VALUE) {
12  
        if (preciseCall_debug)
13  
          print("Method score: " + m + " " + score);
14  
        best.put(m, score);
15  
      }
16  
    }
17  
    Method m = best.get();
18  
    if (m == null) null;
19  
    ret invokeMethod(m, null, args);
20  
  } else {
21  
    throw todo();
22  
  }
23  
}

Author comment

Began life as a copy of #1007856

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018167
Snippet name: preciseCallOpt - better method resolution. Could optimize method lookup
Eternal ID of this version: #1018167/3
Text MD5: c9e79e387c8f896d42289f6ba78901be
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-30 12:16:04
Source code size: 725 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 261 / 306
Version history: 2 change(s)
Referenced in: [show references]