mirror of
https://github.com/curl/curl.git
synced 2025-09-17 09:32:48 +03:00
imap: use ISALNUM() for alphanumeric checks
This commit replaces a self-made character check for alphanumeric characters within imap_is_bchar() with the ISALNUM() macro, as it is reduces the size of the code and makes the performance better, due to ASCII arithmetic. Closes #9289
This commit is contained in:
parent
272f62f171
commit
34886a444f
18
lib/imap.c
18
lib/imap.c
|
@ -83,6 +83,7 @@
|
||||||
#include "bufref.h"
|
#include "bufref.h"
|
||||||
#include "curl_sasl.h"
|
#include "curl_sasl.h"
|
||||||
#include "warnless.h"
|
#include "warnless.h"
|
||||||
|
#include "curl_ctype.h"
|
||||||
|
|
||||||
/* The last 3 #include files should be in this order */
|
/* The last 3 #include files should be in this order */
|
||||||
#include "curl_printf.h"
|
#include "curl_printf.h"
|
||||||
|
@ -1885,22 +1886,17 @@ static char *imap_atom(const char *str, bool escape_only)
|
||||||
*/
|
*/
|
||||||
static bool imap_is_bchar(char ch)
|
static bool imap_is_bchar(char ch)
|
||||||
{
|
{
|
||||||
|
/* Peforming the alnum check with this macro is faster because of ASCII
|
||||||
|
artihmetic */
|
||||||
|
if(ISALNUM(ch))
|
||||||
|
return true;
|
||||||
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
/* bchar */
|
/* bchar */
|
||||||
case ':': case '@': case '/':
|
case ':': case '@': case '/':
|
||||||
/* bchar -> achar */
|
/* bchar -> achar */
|
||||||
case '&': case '=':
|
case '&': case '=':
|
||||||
/* bchar -> achar -> uchar -> unreserved */
|
/* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
|
||||||
case '0': case '1': case '2': case '3': case '4': case '5': case '6':
|
|
||||||
case '7': case '8': case '9':
|
|
||||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
|
|
||||||
case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
|
|
||||||
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
|
|
||||||
case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
|
|
||||||
case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
|
|
||||||
case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
|
|
||||||
case 'v': case 'w': case 'x': case 'y': case 'z':
|
|
||||||
case '-': case '.': case '_': case '~':
|
case '-': case '.': case '_': case '~':
|
||||||
/* bchar -> achar -> uchar -> sub-delims-sh */
|
/* bchar -> achar -> uchar -> sub-delims-sh */
|
||||||
case '!': case '$': case '\'': case '(': case ')': case '*':
|
case '!': case '$': case '\'': case '(': case ')': case '*':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user