bmarwell commented on code in PR #117:
URL: https://github.com/apache/maven-wrapper/pull/117#discussion_r1474170110
##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -70,11 +70,19 @@ set_java_home() {
# hash string like Java String::hashCode
hash_string() {
- str="${1:-}" h=0
- while [ -n "$str" ]; do
- h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$str") ) % 4294967296 ))
- str="${str#?}"
+ str="${1}"
+ length=${#str}
+ h=0
+ # strings start with index 1
+ idx=1
+
+ # lt: skip line break at end
+ while [ $idx -lt "$length" ]; do
+ char=$( printf "%s" "$str" | cut -c $idx )
Review Comment:
The other advantage is that string index starts at 0 😄
--
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]