Skip to content

Commit a6ad3d4

Browse files
tlebfstachura
authored andcommitted
script.sh: short-circuit find-file-doc-comments.pl using an heuristic
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 <theo.lebrun@bootlin.com>
1 parent c0c5d22 commit a6ad3d4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

script.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ parse_docs()
204204
tmpfile=`mktemp`
205205

206206
git cat-file blob "$opt1" > "$tmpfile"
207-
"$script_dir/find-file-doc-comments.pl" "$tmpfile" || exit "$?"
207+
208+
# Shortcut: if '/**' isn't present in the file, it cannot contain a doc.
209+
# This avoids calling find-file-doc-comments.pl on most files, which is an
210+
# expensive operation.
211+
if grep -qF '/**' "$tmpfile"; then
212+
"$script_dir/find-file-doc-comments.pl" "$tmpfile" || exit "$?"
213+
fi
208214

209215
rm -rf "$tmpfile"
210216
}

0 commit comments

Comments
 (0)