You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@yetus.apache.org by aw...@apache.org on 2020/10/07 03:37:12 UTC

[yetus] branch main updated: YETUS-1016. Various performance improvements (#148)

This is an automated email from the ASF dual-hosted git repository.

aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git


The following commit(s) were added to refs/heads/main by this push:
     new af29f39  YETUS-1016. Various performance improvements (#148)
af29f39 is described below

commit af29f394be8c4f104d9fdc9a36fd3c75e92705c0
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Tue Oct 6 20:37:05 2020 -0700

    YETUS-1016. Various performance improvements (#148)
    
    Signed-off-by: Roman Shaposhnik <rv...@apache.org>
---
 precommit/src/main/shell/core.d/00-yetuslib.sh     | 10 +++---
 precommit/src/main/shell/core.d/01-common.sh       | 13 +++----
 .../src/main/shell/test-patch.d/checkstyle.sh      | 26 ++++++++------
 .../src/main/shell/test-patch.d/whitespace.sh      |  8 ++---
 precommit/src/main/shell/test-patch.sh             | 42 +++++++++++++---------
 5 files changed, 58 insertions(+), 41 deletions(-)

diff --git a/precommit/src/main/shell/core.d/00-yetuslib.sh b/precommit/src/main/shell/core.d/00-yetuslib.sh
index 08335f7..cfea284 100755
--- a/precommit/src/main/shell/core.d/00-yetuslib.sh
+++ b/precommit/src/main/shell/core.d/00-yetuslib.sh
@@ -193,7 +193,7 @@ function yetus_generic_columnprinter
   while read -r line; do
     tmpa[${counter}]=${line}
     ((counter=counter+1))
-    option=$(echo "${line}" | cut -f1 -d'@')
+    option="${line%%@*}"
     if [[ ${#option} -gt ${maxoptsize} ]]; then
       maxoptsize=${#option}
     fi
@@ -205,8 +205,8 @@ function yetus_generic_columnprinter
   ((foldsize=numcols-maxoptsize))
 
   until [[ $i -eq ${#tmpa[@]} ]]; do
-    option=$(echo "${tmpa[$i]}" | cut -f1 -d'@')
-    giventext=$(echo "${tmpa[$i]}" | cut -f2 -d'@')
+    option="${tmpa[$i]%%@*}"
+    giventext="${tmpa[$i]##*@}"
 
     while read -r line; do
       printf "%-${maxoptsize}s   %-s\\n" "${option}" "${line}"
@@ -405,7 +405,7 @@ function yetus_sort_array
   declare oifs
   declare -a sa
 
-  globstatus=$(set -o | grep noglob | awk '{print $NF}')
+  globstatus=$(set -o | awk '/noglob/ {print $NF}')
 
   if [[ -n ${IFS} ]]; then
     oifs=${IFS}
@@ -442,7 +442,7 @@ function yetus_sort_and_unique_array
   declare oifs
   declare -a sa
 
-  globstatus=$(set -o | grep noglob | awk '{print $NF}')
+  globstatus=$(set -o | awk '/noglob/ {print $NF}')
 
   if [[ -n ${IFS} ]]; then
     oifs=${IFS}
diff --git a/precommit/src/main/shell/core.d/01-common.sh b/precommit/src/main/shell/core.d/01-common.sh
index 29390d3..9e7d897 100755
--- a/precommit/src/main/shell/core.d/01-common.sh
+++ b/precommit/src/main/shell/core.d/01-common.sh
@@ -729,9 +729,9 @@ function set_yetus_version
     VERSION=$(cat "${BINDIR}/VERSION")
   elif [[ -f "${BINDIR}/../../../pom.xml" ]]; then
     # this way we have no dependency on Maven being installed
-    VERSION=$(${GREP} "<version>" "${BINDIR}/../../../pom.xml" 2>/dev/null \
+    VERSION=$("${GREP}" "<version>" "${BINDIR}/../../../pom.xml" 2>/dev/null \
       | head -1 \
-      | ${SED}  -e 's|^ *<version>||' -e 's|</version>.*$||' 2>/dev/null)
+      | "${SED}"  -e 's|^ *<version>||' -e 's|</version>.*$||' 2>/dev/null)
   fi
 }
 
@@ -804,12 +804,13 @@ function guess_build_tool
 ## @param        module
 function module_file_fragment
 {
-  local mod=$1
-  if [[ ${mod} = \. ]]; then
+  declare mod
+
+  if [[ ${1} = \. ]]; then
     echo root
   else
-    #shellcheck disable=SC1003
-    echo "$1" | tr '/' '_' | tr '\\' '_'
+    mod=${1//\//_}
+    echo "${mod//\\/_}"
   fi
 }
 
diff --git a/precommit/src/main/shell/test-patch.d/checkstyle.sh b/precommit/src/main/shell/test-patch.d/checkstyle.sh
index 27dec9e..9d4339a 100755
--- a/precommit/src/main/shell/test-patch.d/checkstyle.sh
+++ b/precommit/src/main/shell/test-patch.d/checkstyle.sh
@@ -166,6 +166,7 @@ function checkstyle_runner
   declare codeline
   declare cmdresult
   declare -a filelist
+  declare rol
 
   # first, let's clear out any previous run information
   modules_reset
@@ -306,13 +307,14 @@ function checkstyle_runner
 
       # file:linenum:(column:)error    ====>
       # file:linenum:code(:column)\x01:error
-      # \x01 will later used to identify the begining
+      # \x01 will later used to identify the beginning
       # of the checkstyle error message
       pushd "${BASEDIR}" >/dev/null || return 1
       while read -r logline; do
-        file=$(echo "${logline}" | cut -f1 -d:)
-        linenum=$(echo "${logline}" | cut -f2 -d:)
-        text=$(echo "${logline}" | cut -f3- -d:)
+        file=${logline%%:*}
+        rol=${logline/#${file}:}
+        linenum=${rol%%:*}
+        text=${rol/#${linenum}:}
         codeline=$(head -n "+${linenum}" "${file}" | tail -1 )
         {
           echo -n "${file}:${linenum}:${codeline}"
@@ -393,6 +395,7 @@ function checkstyle_postapply
   declare numpatch=0
   declare addpatch=0
   declare summarize=true
+  declare tmpvar
 
   if ! verify_needed_test checkstyle; then
     return 0
@@ -439,12 +442,15 @@ function checkstyle_postapply
         > "${PATCH_DIR}/diff-checkstyle-${fn}.txt"
     fi
 
-    #shellcheck disable=SC2016
-    numbranch=$(wc -l "${PATCH_DIR}/branch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
-    #shellcheck disable=SC2016
-    numpatch=$(wc -l "${PATCH_DIR}/patch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
-    #shellcheck disable=SC2016
-    addpatch=$(wc -l "${PATCH_DIR}/diff-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
+    tmpvar=$(wc -l "${PATCH_DIR}/branch-checkstyle-${fn}.txt")
+    numbranch=${tmpvar%% *}
+
+    tmpvar=$(wc -l "${PATCH_DIR}/patch-checkstyle-${fn}.txt")
+    numpatch=${tmpvar%% *}
+
+    tmpvar=$(wc -l "${PATCH_DIR}/diff-checkstyle-${fn}.txt")
+    addpatch=${tmpvar%% *}
+
 
     ((fixedpatch=numbranch-numpatch+addpatch))
 
diff --git a/precommit/src/main/shell/test-patch.d/whitespace.sh b/precommit/src/main/shell/test-patch.d/whitespace.sh
index 636b71b..4eaef7b 100755
--- a/precommit/src/main/shell/test-patch.d/whitespace.sh
+++ b/precommit/src/main/shell/test-patch.d/whitespace.sh
@@ -139,8 +139,8 @@ function whitespace_postcompile
     ;;
   esac
 
-  # shellcheck disable=SC2016
-  count=$(wc -l "${PATCH_DIR}/whitespace-eol.txt" | ${AWK} '{print $1}')
+  temp1=$(wc -l "${PATCH_DIR}/whitespace-eol.txt")
+  count=${temp1%% *}
 
   if [[ ${count} -gt 0 ]]; then
     if [[ "${BUILDMODE}" = full ]]; then
@@ -159,8 +159,8 @@ function whitespace_postcompile
     ((result=result+1))
   fi
 
-  # shellcheck disable=SC2016
-  count=$(wc -l "${PATCH_DIR}/whitespace-tabs.txt" | ${AWK} '{print $1}')
+  temp1=$(wc -l "${PATCH_DIR}/whitespace-tabs.txt")
+  count=${temp1%% *}
 
   if [[ ${count} -gt 0 ]]; then
     add_vote_table_v2 -1 whitespace \
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index b1af396..a48c3cb 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -2185,24 +2185,29 @@ function bugsystem_linecomments_queue
   declare text
   declare columncheck
   declare column
+  declare rol
+  declare file
 
   if [[ -z "${BUGLINECOMMENTS}" ]]; then
     return 0
   fi
 
   while read -r line; do
-    file=$(echo "${line}" | cut -f1 -d:)
+    file=${line%%:*}
+    rol=${line/#${file}:}
     if [[ "${file}" =~ ^\./ ]]; then
       file=${file:2}
     fi
-    linenum=$(echo "${line}" | cut -f2 -d:)
-    columncheck=$(echo "${line}" | cut -f3 -d:)
+
+    linenum=${rol%%:*}
+    rol=${rol/#${linenum}:}
+    columncheck=${rol%%:*}
     if [[ "${columncheck}" =~ ^[0-9]+$ ]]; then
       column=${columncheck}
-      text=$(echo "${line}" | cut -f4- -d:)
+      text=${rol/#${column}:}
     else
       column="0"
-      text=$(echo "${line}" | cut -f3- -d:)
+      text=${rol}
     fi
 
     echo "${file}:${linenum}:${column}:${plugin}:${text}" >> "${PATCH_DIR}/linecomments-in.txt"
@@ -2231,11 +2236,14 @@ function bugsystem_linecomments_trigger
   sort -k1,1 -k2,2n -k3,3n -k4,4 "${PATCH_DIR}/linecomments-in.txt" > "${PATCH_DIR}/linecomments-sorted.txt"
 
   while read -r line;do
-    fn=$(echo "${line}" | cut -f1 -d:)
-    linenum=$(echo "${line}" | cut -f2 -d:)
-    column=$(echo "${line}" | cut -f3 -d:)
-    plugin=$(echo "${line}" | cut -f4 -d:)
-    text=$(echo "${line}" | cut -f5- -d:)
+    fn=${line%%:*}
+    rol=${line/#${fn}:}
+    linenum=${rol%%:*}
+    rol=${rol/#${linenum}:}
+    column=${rol%%:*}
+    rol=${rol/#${column}:}
+    plugin=${rol%%:*}
+    text=${rol/#${plugin}:}
 
     for bugs in ${BUGLINECOMMENTS}; do
       if declare -f "${bugs}_linecomments" >/dev/null;then
@@ -2637,6 +2645,8 @@ function module_postlog_compare
   declare -i samepatch=0
   declare -i fixedpatch=0
   declare summarize=true
+  declare tmpvar
+
 
   if [[ ${multijdk} == true ]]; then
     jdk=$(report_jvm_version "${JAVA_HOME}")
@@ -2674,10 +2684,10 @@ function module_postlog_compare
     generic_logfilter "${testtype}" "${PATCH_DIR}/branch-${origlog}-${fn}.txt" "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt"
     generic_logfilter "${testtype}" "${PATCH_DIR}/patch-${origlog}-${fn}.txt" "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt"
 
-    # shellcheck disable=SC2016
-    numbranch=$(wc -l "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
-    # shellcheck disable=SC2016
-    numpatch=$(wc -l "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
+    tmpvar=$(wc -l "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt")
+    numbranch=${tmpvar%% *}
+    tmpvar=$(wc -l "${PATCH_DIR}/patch-${origlog}-${testtype}-${fn}.txt")
+    numpatch=${tmpvar%% *}
 
     calcdiffs \
       "${PATCH_DIR}/branch-${origlog}-${testtype}-${fn}.txt" \
@@ -2685,8 +2695,8 @@ function module_postlog_compare
       "${testtype}" \
       > "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt"
 
-    # shellcheck disable=SC2016
-    addpatch=$(wc -l "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt" | "${AWK}" '{print $1}')
+    tmpvar=$(wc -l "${PATCH_DIR}/diff-${origlog}-${testtype}-${fn}.txt")
+    addpatch=${tmpvar%% *}
 
     ((fixedpatch=numbranch-numpatch+addpatch))