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

13
LINES

< > BotCompany Repo | #1025710 // fastJoin - quicker string join on list of non-null strings

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

Libraryless. Click here for Pure Java version (2145L/14K).

sS fastJoin(LS l) {
  if (empty(l)) ret "";
  int n = 0;
  for (S s : l) n += s.length();
  char[] buf = new[n];
  n = 0;
  for (S s : l) {
    int x = s.length();
    s.getChars(0, x, buf, n);
    n += x;
  }
  ret new S(buf);
}

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: #1025710
Snippet name: fastJoin - quicker string join on list of non-null strings
Eternal ID of this version: #1025710/1
Text MD5: a055fd5bf39ccc2cbd4a6c5d1b3c0d55
Transpilation MD5: d80e9b9d38070432f480bd6bfab80f10
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-14 14:13:48
Source code size: 241 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 99 / 156
Referenced in: [show references]