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 824K 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   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, 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: 28 / 4348
Version history: 7 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1028945 & http://1028945.tinybrain.de