yaooqinn commented on code in PR #46894:
URL: https://github.com/apache/spark/pull/46894#discussion_r1630596279
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalogUtils.scala:
##########
@@ -63,22 +63,26 @@ object ExternalCatalogUtils {
bitSet
}
- def needsEscaping(c: Char): Boolean = {
+ @inline private final def needsEscaping(c: Char): Boolean = {
Review Comment:
FYI, I add diff below to avoid NPE.
```diff
def escapePathName2(path: String): String = {
var builder: StringBuilder = null
var i = 0
while (i < path.length) {
val c = path.charAt(i)
if (c < charToEscape.size() && charToEscape.get(c)) {
// Character needs escaping:
if (builder eq null) {
builder = new StringBuilder(path.substring(0, i))
}
builder.append('%')
builder.append(f"${c.asInstanceOf[Int]}%02X")
} else {
+ if (builder eq null) {
+ builder = new StringBuilder()
+ }
// Character does not need escaping:
builder.append(c)
}
i += 1
}
if (builder eq null) {
path
} else {
builder.toString()
}
}
```
I guess the problem with your code is that we can not take a detour into the
original path sting, the StringBuilder cannot be avoided and each character is
appended whether it will be used or not
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]