Skip to content

Commit

Permalink
chore(Cache): stylistic change to not use default (#21707)
Browse files Browse the repository at this point in the history
Purely stylistic change based on the docstring of `default`:

> […] This element does not have any particular specified properties, […]
  • Loading branch information
joneugster committed Feb 11, 2025
1 parent d891bec commit 71cadb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cache/Hashing.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ open System IO

structure HashMemo where
rootHash : UInt64
depsMap : Std.HashMap FilePath (Array FilePath) := {}
cache : Std.HashMap FilePath (Option UInt64) := {}
hashMap : ModuleHashMap := {}
depsMap : Std.HashMap FilePath (Array FilePath) :=
cache : Std.HashMap FilePath (Option UInt64) :=
hashMap : ModuleHashMap :=
deriving Inhabited

partial def insertDeps (hashMap : ModuleHashMap) (path : FilePath) (hashMemo : HashMemo) :
Expand All @@ -33,7 +33,7 @@ Filters the `hashMap` of a `HashMemo` so that it only contains key/value pairs s
-/
def HashMemo.filterByFilePaths (hashMemo : HashMemo) (filePaths : List FilePath) :
IO ModuleHashMap := do
let mut hashMap := default
let mut hashMap :=
for filePath in filePaths do
if hashMemo.hashMap.contains filePath then
hashMap := insertDeps hashMap filePath hashMemo
Expand Down
6 changes: 3 additions & 3 deletions Cache/IO.lean
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ If `keep` is true, the result will contain the entries that do exist;
if `keep` is false, the result will contain the entries that do not exist.
-/
def filterExists (hashMap : ModuleHashMap) (keep : Bool) : IO ModuleHashMap :=
hashMap.foldM (init := default) fun acc path hash => do
hashMap.foldM (init := ) fun acc path hash => do
let exist ← (CACHEDIR / hash.asLTar).pathExists
let add := if keep then exist else !exist
if add then return acc.insert path hash else return acc

def hashes (hashMap : ModuleHashMap) : Lean.RBTree UInt64 compare :=
hashMap.fold (init := default) fun acc _ hash => acc.insert hash
hashMap.fold (init := ) fun acc _ hash => acc.insert hash

end ModuleHashMap

Expand Down Expand Up @@ -384,7 +384,7 @@ instance : Ord FilePath where
compare x y := compare x.toString y.toString

/-- Removes all cache files except for what's in the `keep` set -/
def cleanCache (keep : Lean.RBTree FilePath compare := default) : IO Unit := do
def cleanCache (keep : Lean.RBTree FilePath compare := ) : IO Unit := do
for path in ← getFilesWithExtension CACHEDIR "ltar" do
if !keep.contains path then IO.FS.removeFile path

Expand Down
4 changes: 2 additions & 2 deletions Cache/Requests.lean
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ inductive QueryType
def QueryType.prefix : QueryType → String
| files => "&prefix=f/"
| commits => "&prefix=c/"
| all => default
| all => ""

def formatError {α : Type} : IO α :=
throw <| IO.userError "Invalid format for curl return"
Expand All @@ -299,7 +299,7 @@ def getFilesInfo (q : QueryType) : IO <| List (String × String) := do
let ret ← IO.runCurl #["-X", "GET", s!"{URL}?comp=list&restype=container{q.prefix}"]
match ret.splitOn "<Name>" with
| [] => formatError
| [_] => return default
| [_] => return []
| _ :: parts =>
parts.mapM fun part => match part.splitOn "</Name>" with
| [name, rest] => match rest.splitOn "<Last-Modified>" with
Expand Down

0 comments on commit 71cadb2

Please sign in to comment.