Skip to content

Commit

Permalink
Add caching to parse_dice, to slightly speed things up when called …
Browse files Browse the repository at this point in the history
…with same dice string repeatedly
  • Loading branch information
freiheit committed Mar 21, 2024
1 parent f1e085f commit 47aecf7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mvkroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# https://github.com/freiheit/MvKDiceBot
"""MvKRoller: Dice roller for the MvKDiceBot"""

import functools
import logging
import random
import re
Expand All @@ -40,6 +41,7 @@ def getMessage(self):
return self.message


@functools.cache
def parse_dice(dicestr: str):
"""Parses the dice string and returns a dictionary of dieSize->count"""
# types of dice we're looking for:
Expand Down

0 comments on commit 47aecf7

Please sign in to comment.