Parcourir la source

LibPDF: Remove a pointless template specialization

We can just have two functions with actual names instead of specializing
on a bool template parameter.

No behavior change.
Nico Weber il y a 2 ans
Parent
commit
92d2895057

+ 4 - 6
Userland/Libraries/LibPDF/Encryption.cpp

@@ -95,8 +95,7 @@ StandardSecurityHandler::StandardSecurityHandler(Document* document, size_t revi
 {
 }
 
-template<>
-ByteBuffer StandardSecurityHandler::compute_user_password_value<true>(ByteBuffer password_string)
+ByteBuffer StandardSecurityHandler::compute_user_password_value_v2(ByteBuffer password_string)
 {
     // Algorithm 4: Computing the encryption dictionary's U (user password)
     //              value (Security handlers of revision 2)
@@ -116,8 +115,7 @@ ByteBuffer StandardSecurityHandler::compute_user_password_value<true>(ByteBuffer
     return output;
 }
 
-template<>
-ByteBuffer StandardSecurityHandler::compute_user_password_value<false>(ByteBuffer password_string)
+ByteBuffer StandardSecurityHandler::compute_user_password_value_v3_and_newer(ByteBuffer password_string)
 {
     // Algorithm 5: Computing the encryption dictionary's U (user password)
     //              value (Security handlers of revision 3 or greater)
@@ -177,9 +175,9 @@ bool StandardSecurityHandler::try_provide_user_password(StringView password_stri
     //    supplied password string.
     ByteBuffer password_buffer = MUST(ByteBuffer::copy(password_string.bytes()));
     if (m_revision == 2) {
-        password_buffer = compute_user_password_value<true>(password_buffer);
+        password_buffer = compute_user_password_value_v2(password_buffer);
     } else {
-        password_buffer = compute_user_password_value<false>(password_buffer);
+        password_buffer = compute_user_password_value_v3_and_newer(password_buffer);
     }
 
     // b) If the result of step (a) is equal to the value of the encryption

+ 2 - 2
Userland/Libraries/LibPDF/Encryption.h

@@ -41,8 +41,8 @@ protected:
     void decrypt(NonnullRefPtr<Object>, Reference reference) const override;
 
 private:
-    template<bool is_revision_2>
-    ByteBuffer compute_user_password_value(ByteBuffer password_string);
+    ByteBuffer compute_user_password_value_v2(ByteBuffer password_string);
+    ByteBuffer compute_user_password_value_v3_and_newer(ByteBuffer password_string);
 
     ByteBuffer compute_encryption_key(ByteBuffer password_string);