summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-02 11:11:50 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-02 11:30:16 +0200
commit5935531137a22fdb920921580d491f86adec65c9 (patch)
tree5fa9501621ad327028c2f2e12c9c367f44f6aebe /opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt
parent8bae0f3053a53aac9d483ae97d99f2e7e80b42ef (diff)
perf(trace): Improve performance of column lookup
Diffstat (limited to 'opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt')
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt13
1 files changed, 11 insertions, 2 deletions
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt
index 247e7312..776c40c0 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TableColumn.kt
@@ -39,7 +39,7 @@ public class TableColumn<out T>(public val name: String, type: Class<T>) {
* Determine whether the type of the column is a subtype of [column].
*/
public fun isAssignableTo(column: TableColumn<*>): Boolean {
- return type.isAssignableFrom(column.type)
+ return name == column.name && type.isAssignableFrom(column.type)
}
/**
@@ -50,7 +50,16 @@ public class TableColumn<out T>(public val name: String, type: Class<T>) {
/**
* Determine whether this column is equal to [other].
*/
- public override fun equals(other: Any?): Boolean = other is TableColumn<*> && name == other.name && type == other.type
+ public override fun equals(other: Any?): Boolean {
+ // Fast-path: reference equality
+ if (this === other) {
+ return true
+ } else if (other == null || other !is TableColumn<*>) {
+ return false
+ }
+
+ return name == other.name && type == other.type
+ }
/**
* Return a string representation of this column.