Another factor in the cost of the lookup algorithm is con-nected with the strings themselves. Simple string com-parison is used on the symbol names which are storedin a string table associated with the symbol table datastructures. Strings are stored in the C-format; they areterminated by a NUL byte and no initial length field isused. This means string comparisons has to proceed untila non-matching character is found or until the end of thestring. This approach is susceptible to long strings withcommon prefixes. Unfortunately this is not uncommon.Код: [Вибрати]namespace some_namespace { class some_longer_class_name { int member_variable; public: some_longer_class_name (int p); int the_getter_function (void); };}In the new mangling scheme used in today's gcc versionsand all other compilers which are compatible with thecommon C++ ABI the names start with the namespacesand class names and end with the member names. Fig-ure 6 shows the result for the little example. The manglednames for the two member functions differs only after the43rd character. This is really bad performance-wise if thetwo symbols should fall into the same hash bucket.Код: [Вибрати]_ZN14some_namespace22some_longer_class_nameC1Ei_ZN14some_namespace22some_longer_class_name19the_getter_functionEvFigure 6: Mangled names using the common C++ ABI scheme
namespace some_namespace { class some_longer_class_name { int member_variable; public: some_longer_class_name (int p); int the_getter_function (void); };}
_ZN14some_namespace22some_longer_class_nameC1Ei_ZN14some_namespace22some_longer_class_name19the_getter_functionEv