Skip to content

Commit

Permalink
Revert "Implement lastCompute" (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
dphfox authored Feb 1, 2025
1 parent 16a1619 commit a2a4e6b
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 24 deletions.
13 changes: 1 addition & 12 deletions docs/api-reference/graph/types/graphobject.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export type GraphObject = ScopedObject & {
dependencySet: {[GraphObject]: unknown},
dependentSet: {[GraphObject]: unknown},
lastChange: number?,
lastCompute: number?,
timeliness: "lazy" | "eager",
validity: "valid" | "invalid" | "busy",
_evaluate: (GraphObject) -> boolean
_evaluate: (GraphObject, lastChange: number?) -> boolean
}
```

Expand Down Expand Up @@ -76,16 +75,6 @@ object.
The `os.clock()` time of this object's most recent meaningful change, or `nil`
if the object is newly created.

<h3 markdown>
lastCompute
<span class="fusiondoc-api-type">
: number?
</span>
</h3>

The `os.clock()` time of when this object was most recently computed, or `nil`
if the object is newly created.

<h3 markdown>
timeliness
<span class="fusiondoc-api-type">
Expand Down
1 change: 0 additions & 1 deletion src/Animation/ExternalTime.luau
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ local function ExternalTime(
createdAt = createdAt,
dependentSet = {},
lastChange = nil,
lastCompute = nil,
scope = scope,
validity = "invalid"
},
Expand Down
1 change: 0 additions & 1 deletion src/Animation/Spring.luau
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ local function Spring<T>(
dependencySet = {},
dependentSet = {},
lastChange = nil,
lastCompute = nil,
scope = scope,
validity = "invalid",
_activeDamping = -1,
Expand Down
1 change: 0 additions & 1 deletion src/Animation/Stopwatch.luau
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ local function Stopwatch(
dependencySet = {},
dependentSet = {},
lastChange = nil,
lastCompute = nil,
scope = scope,
validity = "invalid",
_EXTREMELY_DANGEROUS_usedAsValue = 0,
Expand Down
1 change: 0 additions & 1 deletion src/Animation/Tween.luau
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ local function Tween<T>(
dependencySet = {},
dependentSet = {},
lastChange = nil,
lastCompute = nil,
scope = scope,
validity = "invalid",
_activeDuration = nil,
Expand Down
5 changes: 2 additions & 3 deletions src/Graph/evaluate.luau
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ local function evaluate(
if target.validity == "busy" then
return External.logError("infiniteLoop")
end
local firstEvaluation = target.lastCompute == nil or target.lastChange == nil
local firstEvaluation = target.lastChange == nil
local isInvalid = target.validity == "invalid"
if firstEvaluation or isInvalid or forceComputation then
local needsComputation = firstEvaluation or forceComputation
if not needsComputation then
for dependency in target.dependencySet do
evaluate(dependency, false)
if dependency.lastChange > target.lastCompute then
if dependency.lastChange > target.lastChange then
needsComputation = true
break
end
Expand All @@ -42,7 +42,6 @@ local function evaluate(
end
target.validity = "busy"
targetMeaningfullyChanged = target:_evaluate() or firstEvaluation
target.lastCompute = os.clock()
end
if targetMeaningfullyChanged then
target.lastChange = os.clock()
Expand Down
1 change: 0 additions & 1 deletion src/State/Computed.luau
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ local function Computed<T, S>(
dependencySet = {},
dependentSet = {},
lastChange = nil,
lastCompute = nil,
scope = scope,
validity = "invalid",
_EXTREMELY_DANGEROUS_usedAsValue = nil,
Expand Down
1 change: 0 additions & 1 deletion src/State/Value.luau
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ local function Value<T>(
createdAt = createdAt,
dependentSet = {},
lastChange = os.clock(),
lastCompute = os.clock(),
scope = scope,
validity = "valid",
_EXTREMELY_DANGEROUS_usedAsValue = initialValue
Expand Down
1 change: 0 additions & 1 deletion src/Types.luau
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export type GraphObject = ScopedObject & {
dependencySet: {[GraphObject]: unknown},
dependentSet: {[GraphObject]: unknown},
lastChange: number?,
lastCompute: number?,
timeliness: "lazy" | "eager",
validity: "valid" | "invalid" | "busy",
_evaluate: (GraphObject) -> boolean
Expand Down
1 change: 0 additions & 1 deletion test/Spec/Graph/evaluate.spec.luau
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ return function()
local seen = {}
for _, searchTarget in searchNow do
searchTarget.lastChange = -depth
searchTarget.lastCompute = -depth
searchTarget.validity = if depth == 0 then "valid" else "invalid"
for dependent in searchTarget.dependentSet do
if seen[dependent] then
Expand Down
1 change: 0 additions & 1 deletion test/Util/Graphs.luau
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ function Graphs.make(
dependencySet = {},
dependentSet = {},
lastChange = nil,
lastCompute = nil,
timeliness = "lazy" :: "lazy",
validity = "valid" :: "valid",
_evaluate = function()
Expand Down

0 comments on commit a2a4e6b

Please sign in to comment.