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

!7

cprint CacheAllSnippets {
  transient SS texts; // snippet ID to uppercase text
  transient SS titles; // snipppet ID to title
  
  start-thread {
    time "Loaded all snippet texts & titles" {
      new SS texts;
      new SS titles;
      for (virtual CSnippet sn : dm_allSnippets()) {
        S snippetID = (S) rcall snippetID(sn);
        texts.put(snippetID, upper((S) rcall text(sn)));
        titles.put(snippetID, getString title(sn));
      }
      setFields(+texts, +titles);
    }
    print("Loaded " + nSnippets(texts) + ", " + nChars(totalStringLength(values(texts))));
  }
  
  // API
  
  // id to uppercase text
  SS getData() {
    sleepWhile(() -> texts == null, max := 10.0);
    ret texts;
  }
  
  SS getTitles() {
    sleepWhile(() -> titles == null, max := 10.0);
    ret titles;
  }
}

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: 265 / 5012
Version history: 7 change(s)
Referenced in: [show references]