commit af6dd184d69b0d87751b6210c36c3f24370c389f
parent f6b5ec5869da147ab6c107cd616195f0b9c2c6c8
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Tue, 21 Nov 2023 15:58:31 +0300
Micro-optimisations for non-overridable FD_SETSIZE
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -732,6 +732,11 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh,
const MHD_socket mhd_sckt = urh->mhd.socket;
bool res = true;
+#ifndef HAS_FD_SETSIZE_OVERRIDABLE
+ (void) fd_setsize; /* Mute compiler warning */
+ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */
+#endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */
+
/* Do not add to 'es' only if socket is closed
* or not used anymore. */
if (MHD_INVALID_SOCKET != conn_sckt)
@@ -991,6 +996,11 @@ internal_get_fdset2 (struct MHD_Daemon *daemon,
enum MHD_Result result = MHD_YES;
MHD_socket ls;
+#ifndef HAS_FD_SETSIZE_OVERRIDABLE
+ (void) fd_setsize; /* Mute compiler warning */
+ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */
+#endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */
+
if (daemon->shutdown)
return MHD_YES;
@@ -1198,6 +1208,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
#endif /* HAVE_MESSAGES */
return MHD_NO;
}
+ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */
#endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */
#ifdef EPOLL_SUPPORT
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c
@@ -386,6 +386,12 @@ MHD_add_to_fd_set_ (MHD_socket fd,
if ( (NULL == set) ||
(MHD_INVALID_SOCKET == fd) )
return 0;
+
+#ifndef HAS_FD_SETSIZE_OVERRIDABLE
+ (void) fd_setsize; /* Mute compiler warning */
+ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */
+#endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */
+
if (! MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (fd,
set,
fd_setsize))