Skip to content

Commit

Permalink
script.sh: short-circuit find-file-doc-comments.pl using an heuristic
Browse files Browse the repository at this point in the history
Avoid calling this parse-docs script that is expensive. This heuristic
avoids running it on most files, and is almost free.

Signed-off-by: Théo Lebrun <[email protected]>
  • Loading branch information
tleb authored and fstachura committed Dec 21, 2024
1 parent ec9d0b6 commit 3622d67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ parse_docs()
tmpfile=`mktemp`

git cat-file blob "$opt1" > "$tmpfile"
"$script_dir/find-file-doc-comments.pl" "$tmpfile" || exit "$?"

# Shortcut: if '/**' isn't present in the file, it cannot contain a doc.
# This avoids calling find-file-doc-comments.pl on most files, which is an
# expensive operation.
if grep -qF '/**' "$tmpfile"; then
"$script_dir/find-file-doc-comments.pl" "$tmpfile" || exit "$?"
fi

rm -rf "$tmpfile"
}
Expand Down

0 comments on commit 3622d67

Please sign in to comment.