diff options
author | nyamatongwe <devnull@localhost> | 2000-07-06 14:15:41 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-07-06 14:15:41 +0000 |
commit | a84bed826e318748cfd2473005ec68c97959156a (patch) | |
tree | 9d0b611cd37c387ae32fbb18c45e3b6c0b09b800 /include/PropSet.h | |
parent | 7becad30859bf44144ec7a35d29dc1500f2670d1 (diff) | |
download | scintilla-mirror-a84bed826e318748cfd2473005ec68c97959156a.tar.gz |
Optimisations.
Diffstat (limited to 'include/PropSet.h')
-rw-r--r-- | include/PropSet.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/include/PropSet.h b/include/PropSet.h index 4e30c37c5..ed580ee96 100644 --- a/include/PropSet.h +++ b/include/PropSet.h @@ -11,12 +11,16 @@ bool EqualCaseInsensitive(const char *a, const char *b); // Define another string class. // While it would be 'better' to use std::string, that doubles the executable size. -inline char *StringDup(const char *s) { +inline char *StringDup(const char *s, int len=-1) { if (!s) return 0; - char *sNew = new char[strlen(s) + 1]; - if (sNew) - strcpy(sNew, s); + if (len == -1) + len = strlen(s); + char *sNew = new char[len + 1]; + if (sNew) { + strncpy(sNew, s, len); + sNew[len] = '\0'; + } return sNew; } @@ -103,9 +107,18 @@ public: } }; +unsigned int HashString(const char *s); + +struct Property { + unsigned int hash; + char *key; + char *val; + Property() : hash(0), key(0), val(0) {} +}; + class PropSet { private: - char **vals; + Property *properties; int size; int used; void EnsureCanAddEntry(); @@ -116,6 +129,8 @@ public: void Set(const char *key, const char *val); void Set(char *keyval); SString Get(const char *key); + SString GetExpanded(const char *key); + SString Expand(const char *withvars); int GetInt(const char *key, int defaultValue=0); SString GetWild(const char *keybase, const char *filename); SString GetNewExpand(const char *keybase, const char *filename); |