Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.22.0: Caching probabilities calculation across objects #79

Merged
merged 5 commits into from
Jul 2, 2020

Conversation

Samasaur1
Copy link
Owner

@Samasaur1 Samasaur1 commented Jul 2, 2020

Here's what's new:

More detail on caching:

Use case

Here's an excerpt from that issue:

let first = Dice(.d4, count: 10)
first.probabilities

let second = first
second.probabilities

let third = Dice(.d4, count: 10) // functionally identical
third.probabilities

In the current version, second does not need to repeat its calculations, but third does. Caching means that third will not need to repeat the calculations. Neither would any other Dice object that represents 10d4.

Disabling caching

Caching is on by default, but it can easily be disabled. There are two ways to disable it, in order to be future-proof:

Dice.enableCaching //true
DiceKit.enableCaching //true

Dice.enableCaching = false

Dice.enableCaching //false
DiceKit.enableCaching //false

DiceKit.enableCaching = true

Dice.enableCaching //true
DiceKit.enableCaching //true

Basically, Dice.enableCaching enables/disables the cache for Dice only, while DiceKit.enableCaching sets caching for every type that supports it (currently only Dice) and gets whether all caching types have caching enabled. For example:

Dice.enableCaching = true
SomeFutureCachingType.enableCaching = false

DiceKit.enableCaching //false

DiceKit.enableCaching = true

Dice.enableCaching //true
SomeFutureCachingType.enableCaching //true

DiceKit.enableCaching = false

Dice.enableCaching //false
SomeFutureCachingType.enableCaching //false

Here's what has to happen:

  • Update the documentation on all the enableCaching members (I renamed it a bunch while writing, and I don't think it is correct)
  • Add a Caching/Cachable protocol that Dice conforms to
  • Ensure the changelog has everything new that is being added
  • Bump version (run updateVersion.sh)
  1. Wait for CI
  2. Merge
  3. Run release.sh

Samasaur1 and others added 3 commits July 1, 2020 17:44
This also adds Hashable support (a requirement for using
`Dice` as the key for a dictionary)

Closes #78
@Samasaur1 Samasaur1 added the enhancement New feature or request label Jul 2, 2020
@Samasaur1
Copy link
Owner Author

Samasaur1 commented Jul 2, 2020

Warnings
⚠️ Sources/DiceKit/Caching.swift was changed, but there is no file at path Tests/DiceKitTests/CachingTests.swift. Maybe it's under a different path, or maybe there are no tests
⚠️ Sources/DiceKit/Typealiases.swift was changed, but there is no file at path Tests/DiceKitTests/TypealiasesTests.swift. Maybe it's under a different path, or maybe there are no tests
⚠️ Sources/DiceKit/Dice.swift was changed, but Tests/DiceKitTests/DiceTests.swift wasn't! You should probably test the new behavior
Messages
📖

Task 4 completed: Bump version (run updateVersion.sh)

📖

Task 3 completed: Ensure the changelog has everything new that is being added

📖

Task 2 completed: Add a Caching/Cachable protocol that Dice conforms to

📖

Task 1 completed: Update the documentation on all the enableCaching members (I renamed it a bunch while writing, and I don't think it is correct)

📖 An XCTestManifests file was updated, but be sure it has ALL the new tests!
📖 Sources/DiceKit/Chances.swift has had corresponding changes in its test file
📖 The latest date in the CHANGELOG is today, 2020-07-02
📖 The new version is v0.22.0

Generated by 🚫 Danger Swift against 740c609

@Samasaur1 Samasaur1 merged commit e8876a1 into master Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache calculated probabilities across Dice objects
1 participant