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

12
LINES

< > BotCompany Repo | #1011692 // internPerProgram - intern a string in a program-held list

JavaX fragment (include)

static WeakHashMap2 internPerProgram_map = new WeakHashMap2;

static S internPerProgram(S s) {
  if (s == null) null;
   synchronized(internPerProgram_map) {
    WeakHashMap2.Entry<S, Bool> e = internPerProgram_map.getEntry(s);
    S sym = e == null ? null : (S) e.get();
    if (sym == null)
      internPerProgram_map.put(sym = s, Bool.TRUE);
    ret sym;
  }
}

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: #1011692
Snippet name: internPerProgram - intern a string in a program-held list
Eternal ID of this version: #1011692/3
Text MD5: 8e5545ffc0199a2d73f75d3aa0258dbe
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-03 17:26:54
Source code size: 376 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 418 / 473
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1011729 - fastIntern - VM-wide intern - faster alternative to String.intern()