From 5587414110fed279876daf701d6fd782ad431cc2 Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:37:21 +0000 Subject: [PATCH] STY: Refactor check_if_whitespace_only (#2950) --- pypdf/_utils.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pypdf/_utils.py b/pypdf/_utils.py index 20d14c387..df652d4d7 100644 --- a/pypdf/_utils.py +++ b/pypdf/_utils.py @@ -202,11 +202,7 @@ def check_if_whitespace_only(value: bytes) -> bool: True if the value only has whitespace characters, otherwise return False. """ - for index in range(len(value)): - current = value[index : index + 1] - if current not in WHITESPACES: - return False - return True + return all(b in WHITESPACES_AS_BYTES for b in value) def skip_over_comment(stream: StreamType) -> None: