Skip to content

Commit 7389b50

Browse files
committed
Support CharSequence queries
1 parent e4d2d8a commit 7389b50

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

class-match/src/main/java/datadog/instrument/classmatch/ClassInfoCache.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public ClassInfoCache(int capacity) {
5757
* @param className the class-name
5858
* @return information shared under the class-name
5959
*/
60-
public T find(String className) {
60+
public T find(CharSequence className) {
6161
return find(className, ALL_CLASS_LOADERS);
6262
}
6363

@@ -78,7 +78,7 @@ public void share(String className, T info) {
7878
* @param cl the class-loader
7979
* @return information shared under the class-name and class-loader
8080
*/
81-
public T find(String className, ClassLoader cl) {
81+
public T find(CharSequence className, ClassLoader cl) {
8282
return find(className, ClassLoaderIndex.getClassLoaderKeyId(cl));
8383
}
8484

@@ -102,7 +102,7 @@ public void share(String className, T info, ClassLoader cl) {
102102
* @see ClassLoaderIndex#getClassLoaderKeyId(ClassLoader)
103103
*/
104104
@SuppressWarnings("unchecked")
105-
public T find(String className, int classLoaderKeyId) {
105+
public T find(CharSequence className, int classLoaderKeyId) {
106106
final int hash = className.hashCode();
107107
final SharedInfo[] shared = this.shared;
108108
final int slotMask = this.slotMask;
@@ -112,7 +112,7 @@ public T find(String className, int classLoaderKeyId) {
112112
int slot = slotMask & h;
113113
SharedInfo existing = shared[slot];
114114
if (existing != null) {
115-
if (className.equals(existing.className)) {
115+
if (existing.className.contentEquals(className)) {
116116
// filter on class-loader, -1 on either side matches all
117117
if ((classLoaderKeyId ^ existing.classLoaderKeyId) <= 0) {
118118
// use global TICKS as a substitute for access time

class-match/src/main/java/datadog/instrument/classmatch/ClassNameFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public ClassNameFilter(int capacity) {
4949
* @param className the class-name to test
5050
* @return {@code true} if the class-name is in the filter; otherwise {@code false}
5151
*/
52-
public boolean contains(String className) {
52+
public boolean contains(CharSequence className) {
5353
final int hash = className.hashCode();
5454
final long[] members = this.members;
5555
final int slotMask = this.slotMask;
@@ -120,7 +120,7 @@ private static int classCode(String className) {
120120
}
121121

122122
/** Checks whether the 32-bit 'class-code' is consistent with the fully-qualified class-name. */
123-
private static boolean checkClassCode(String className, int code) {
123+
private static boolean checkClassCode(CharSequence className, int code) {
124124
int start = (0xFF & code);
125125
int end = className.length() - 1;
126126
return end - start == (0xFF & (code >> 8))

0 commit comments

Comments
 (0)