diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-03-30 12:38:38 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-03-30 12:38:38 +0200 |
commit | 6dc60370a750334cb701386cfa4ef9719db9078a (patch) | |
tree | da472df5380711af32eefa61c6220ed2520ade6d /apt-pkg/contrib/strutl.h | |
parent | b569b4650c647c3aef5341c40d208a37211b57aa (diff) |
replace every call to toupper with one to our own tolower_ascii
This sounds like a premature optimization and since Mr. Knuth we all
know that they are the root of all evil - but, and here it starts to be
interesting: As the tolower_ascii method is by far the most called
method we have (~60 Mio. times) and as we compare only strings containing
ascii characters (package names, configuration options) using our own
method reduces execution time of APT by 4% plus it avoids that the
locale settings can influence us.
Diffstat (limited to 'apt-pkg/contrib/strutl.h')
-rw-r--r-- | apt-pkg/contrib/strutl.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index e72288f4c..cdf78f317 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -25,19 +25,12 @@ #include <iostream> #include <time.h> +#include "macros.h" + using std::string; using std::vector; using std::ostream; -#ifdef __GNUG__ -// Methods have a hidden this parameter that is visible to this attribute -#define APT_FORMAT2 __attribute__ ((format (printf, 2, 3))) -#define APT_FORMAT3 __attribute__ ((format (printf, 3, 4))) -#else -#define APT_FORMAT2 -#define APT_FORMAT3 -#endif - bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest); char *_strstrip(char *String); char *_strtabexpand(char *String,size_t Len); @@ -60,11 +53,11 @@ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); vector<string> ExplodeString(string const &haystack, char const &split); -void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; -void strprintf(string &out,const char *format,...) APT_FORMAT2; -char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3; +void ioprintf(ostream &out,const char *format,...) __like_printf(2); +void strprintf(string &out,const char *format,...) __like_printf(2); +char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3); bool CheckDomainList(const string &Host, const string &List); -int tolower_ascii(int c); +int tolower_ascii(int const c) __attrib_const __hot; #define APT_MKSTRCMP(name,func) \ inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \ @@ -144,6 +137,4 @@ struct RxChoiceList unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin, const char **ListEnd); -#undef APT_FORMAT2 - #endif |