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).

1  
sS fastJoin(LS l) {
2  
  if (empty(l)) ret "";
3  
  int n = 0;
4  
  for (S s : l) n += s.length();
5  
  char[] buf = new[n];
6  
  n = 0;
7  
  for (S s : l) {
8  
    int x = s.length();
9  
    s.getChars(0, x, buf, n);
10  
    n += x;
11  
  }
12  
  ret new S(buf);
13  
}

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: 180 / 259
Referenced in: [show references]