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

33
LINES

< > BotCompany Repo | #1028945 // Cache All Snippets With Text [cached in upper case for faster searching]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (2638L/14K).

1  
!7
2  
3  
cprint CacheAllSnippets {
4  
  transient SS texts; // snippet ID to uppercase text
5  
  transient SS titles; // snipppet ID to title
6  
  
7  
  start-thread {
8  
    time "Loaded all snippet texts & titles" {
9  
      new SS texts;
10  
      new SS titles;
11  
      for (virtual CSnippet sn : dm_allSnippets()) {
12  
        S snippetID = (S) rcall snippetID(sn);
13  
        texts.put(snippetID, upper((S) rcall text(sn)));
14  
        titles.put(snippetID, getString title(sn));
15  
      }
16  
      setFields(+texts, +titles);
17  
    }
18  
    print("Loaded " + nSnippets(texts) + ", " + nChars(totalStringLength(values(texts))));
19  
  }
20  
  
21  
  // API
22  
  
23  
  // id to uppercase text
24  
  SS getData() {
25  
    sleepWhile(() -> texts == null, max := 10.0);
26  
    ret texts;
27  
  }
28  
  
29  
  SS getTitles() {
30  
    sleepWhile(() -> titles == null, max := 10.0);
31  
    ret titles;
32  
  }
33  
}

Author comment

Began life as a copy of #1028144

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1028945
Snippet name: Cache All Snippets With Text [cached in upper case for faster searching]
Eternal ID of this version: #1028945/8
Text MD5: 7da1e7d866cb40200e82121923a1baa1
Transpilation MD5: b7d437489073f3e6b6c2006964c40000
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-12 20:20:41
Source code size: 846 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 267 / 5014
Version history: 7 change(s)
Referenced in: [show references]