]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: micro optimization for AppProtoEquals
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Dec 2023 16:01:18 +0000 (17:01 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 8 Jan 2024 19:23:28 +0000 (20:23 +0100)
Add most common condition first.

src/app-layer-protos.h

index dd372550cbf58573d98dc1c3e9e6b38b671279ae..e2efbec4d4b1791f078facd0fbd437418883cd5d 100644 (file)
@@ -87,14 +87,16 @@ static inline bool AppProtoIsValid(AppProto a)
 // whether a signature AppProto matches a flow (or signature) AppProto
 static inline bool AppProtoEquals(AppProto sigproto, AppProto alproto)
 {
+    if (sigproto == alproto) {
+        return true;
+    }
     switch (sigproto) {
         case ALPROTO_HTTP:
-            return (alproto == ALPROTO_HTTP1) || (alproto == ALPROTO_HTTP2) ||
-                   (alproto == ALPROTO_HTTP);
+            return (alproto == ALPROTO_HTTP1) || (alproto == ALPROTO_HTTP2);
         case ALPROTO_DCERPC:
-            return (alproto == ALPROTO_DCERPC || alproto == ALPROTO_SMB);
+            return (alproto == ALPROTO_SMB);
     }
-    return (sigproto == alproto);
+    return false;
 }
 
 /**