Skip to content

Commit

Permalink
Merge pull request #4 from xiv-gear-planner/optimize-recipe-memory
Browse files Browse the repository at this point in the history
Reduce memory used for recipes
  • Loading branch information
xpdota authored Sep 12, 2024
2 parents aa8aeb3 + 14838a9 commit aa4fedd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/xivgear_data_api__run_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class DataManager implements AutoCloseable {
)
)
List<ItemBase> itemBases = client.getSearchIterator(ItemBase, itemFilter).toList().toSorted { it.rowId }
Set<Integer> itemIds = itemBases.collect { it.rowId }.toSet()
log.info "Loaded ${itemBases.size()} Items"

log.info "Loading Recipes"
Expand All @@ -227,8 +228,12 @@ class DataManager implements AutoCloseable {
// )
)
List<Recipe> recipes = client.getSearchIterator(Recipe, recipeFilter).toList()
Set<Integer> itemsWithRecipes = recipes.collect { it.itemResult }.toSet()
log.info "Loaded ${recipes.size()} Recipes"
// Only retain items that were in our original result set
Set<Integer> itemsWithRecipes = recipes
.collect { it.itemResult }
.findAll { it in itemIds }
.toSet()
log.info "Loaded ${itemsWithRecipes.size()} Recipes"

// There is currently no good way to do shops. SpecialShop items have a 60-item "Items" array which results
// in a massive response. It is too slow and bloated to consume raw. Trying to filter also results in
Expand Down

0 comments on commit aa4fedd

Please sign in to comment.