Skip to content

Commit

Permalink
Get rid of org.apache.commons.lang.builder.HashCodeBuilder usages, …
Browse files Browse the repository at this point in the history
…as it is absent in v233
  • Loading branch information
fan-tom committed Oct 15, 2023
1 parent d2d9c00 commit 1f65d24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package com.github.fantom.codeowners.indexing
import com.github.fantom.codeowners.OwnersReference
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import org.apache.commons.lang.StringUtils
import org.apache.commons.lang.builder.HashCodeBuilder
import java.io.DataInput
import java.io.DataOutput
import java.io.IOException
import java.io.Serializable
import java.util.*

@JvmInline
value class RegexString(val regex: String) {
Expand Down Expand Up @@ -65,7 +64,7 @@ class CodeownersEntryOccurrence(private val url: String, val items: List<Pair<Re
val url = input.readUTF()
val items = mutableListOf<Pair<RegexString, OwnersReference>>()

if (!StringUtils.isEmpty(url)) {
if (url.isNotEmpty()) {
val size = input.readInt()
repeat((0 until size).count()) {
val pattern = RegexString(input.readUTF())
Expand All @@ -82,9 +81,7 @@ class CodeownersEntryOccurrence(private val url: String, val items: List<Pair<Re
}
}

override fun hashCode() = HashCodeBuilder().append(url).apply {
items.forEach { append(it.first).append(it.second) }
}.toHashCode()
override fun hashCode() = Objects.hash(url, items)

override fun equals(other: Any?) = when {
other !is CodeownersEntryOccurrence -> false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.fantom.codeowners.util.MatcherUtil
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.util.containers.IntObjectCache
import org.apache.commons.lang.builder.HashCodeBuilder
import java.util.*
import java.util.regex.Pattern

@Service(Service.Level.APP)
Expand All @@ -25,7 +25,7 @@ class CodeownersMatcher : Disposable {
return false
}
synchronized(cache) {
val hashCode = HashCodeBuilder().append(pattern).append(path).toHashCode()
val hashCode = Objects.hash(pattern, path)
if (!cache.containsKey(hashCode)) {
val parts = MatcherUtil.getParts(pattern)
var result = false
Expand Down

0 comments on commit 1f65d24

Please sign in to comment.