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

13
LINES

< > BotCompany Repo | #1024843 // internByteArrayField - share equal byte arrays between objects

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2039L/13K).

svoid mapMethodLike internByteArrayField(S field, Cl l) {
  HashMap<HashedByteArray, byte[]> map = new HashMap;
  fOr (O o : l) {
    byte[] value = cast getOpt(o, field);
    if (value == null) continue;
    HashedByteArray hashed = new(value);
    byte[] existing = map.get(hashed);
    if (existing != null)
      setOpt(o, field, existing);
    else
      map.put(hashed, value);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024843
Snippet name: internByteArrayField - share equal byte arrays between objects
Eternal ID of this version: #1024843/6
Text MD5: d6ed2d38dd5123debb04b4ea81153555
Transpilation MD5: 8101860b50d4b9cd40358edc8662944b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-26 21:58:04
Source code size: 401 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 230 / 357
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)