-
Notifications
You must be signed in to change notification settings - Fork 1
Initial structure #1
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
Conversation
fd9258c to
fa0d8ea
Compare
src/main/kotlin/Main.kt
Outdated
| } | ||
|
|
||
| fun calculateExecHash(str: String): String { | ||
| return MessageDigest.getInstance("SHA-256").digest(str.toByteArray()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should save the the MessageDigest instance instead of getting it each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/main/kotlin/MergedSpawnExec.kt
Outdated
| class MergedSpawnExec( | ||
| val listedOutputs: List<String>, | ||
| val aEnvVars: Map<String, String>?, | ||
| val aInputs: Map<String, Digest>? | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be just a class with: listedOutputs, envVars and inputs? Why do you put in two versions? Just store them in a separate list in main, e.g: spawnSpecsA and mergedSpawnSpecs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if you had to keep this structure (which I don't recommend), you could have this as a data class:
data class MergedSpawnSpec(
val listedOutputs: List<String>,
val aEnvVars: Map<String, String>?,
val aInputs: Map<String, Digest>?,
var bEnvVars: Map<String, String> = HashMap(),
var bInputs: Map<String, Digest> = HashMap(),
var presentInBothExecs: Boolean = false,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listedOutputs are the same for both executions but inputs and envVars may be different. So I need to save both to compare them later on or only save those that are different in MergedSpawnExec instance
src/main/kotlin/Main.kt
Outdated
| return Pair(execHash, spawnExec) | ||
| } | ||
|
|
||
| fun calculateExecHash(str: String): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str is used in both the function name as well as in the lambda, so the function variable is shadowed. Better to have different names, because this could lead to confusing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| MergedSpawnExec( | ||
| spawnExec.second.listedOutputsList, | ||
| spawnExec.second.environmentVariablesList.associate { it.name to it.value }, | ||
| spawnExec.second.inputsList.associate { it.path to it.digest } | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this should be one class, and for pathB you want some other class.
No description provided.