From 8f4247427c789c2bcdafcb5f5bedc01362998dbf Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 12 Nov 2016 17:47:25 +1100 Subject: [PATCH] Rearranged WebPImagePlugin _accept for speed --- PIL/WebPImagePlugin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/PIL/WebPImagePlugin.py b/PIL/WebPImagePlugin.py index 6837b53be..eacc7c5a8 100644 --- a/PIL/WebPImagePlugin.py +++ b/PIL/WebPImagePlugin.py @@ -17,11 +17,9 @@ _VP8_MODES_BY_IDENTIFIER = { def _accept(prefix): - is_riff_file_format = prefix[:4] == b"RIFF" - is_webp_file = prefix[8:12] == b"WEBP" - is_valid_vp8_mode = prefix[12:16] in _VP8_MODES_BY_IDENTIFIER - - return is_riff_file_format and is_webp_file and is_valid_vp8_mode + return (prefix[:4] == b"RIFF" # RIFF file format + and prefix[8:12] == b"WEBP" # WEBP file + and prefix[12:16] in _VP8_MODES_BY_IDENTIFIER) # Valid VP8 mode class WebPImageFile(ImageFile.ImageFile):