Commit 2a495115 authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid

Add some const to GooHash and GooString

parent e491e935
......@@ -14,6 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -154,7 +155,7 @@ void *GooHash::lookup(GooString *key) {
return p->val.p;
}
int GooHash::lookupInt(GooString *key) {
int GooHash::lookupInt(const GooString *key) {
GooHashBucket *p;
int h;
......@@ -351,7 +352,7 @@ void GooHash::expand() {
gfree(oldTab);
}
GooHashBucket *GooHash::find(GooString *key, int *h) {
GooHashBucket *GooHash::find(const GooString *key, int *h) {
GooHashBucket *p;
if (unlikely(!key))
......@@ -378,7 +379,7 @@ GooHashBucket *GooHash::find(const char *key, int *h) {
return nullptr;
}
int GooHash::hash(GooString *key) {
int GooHash::hash(const GooString *key) {
const char *p;
unsigned int h;
int i;
......
......@@ -14,6 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -45,7 +46,7 @@ public:
void replace(GooString *key, void *val);
void replace(GooString *key, int val);
void *lookup(GooString *key);
int lookupInt(GooString *key);
int lookupInt(const GooString *key);
void *lookup(const char *key);
int lookupInt(const char *key);
void *remove(GooString *key);
......@@ -63,9 +64,9 @@ private:
GooHash& operator=(const GooHash &other);
void expand();
GooHashBucket *find(GooString *key, int *h);
GooHashBucket *find(const GooString *key, int *h);
GooHashBucket *find(const char *key, int *h);
int hash(GooString *key);
int hash(const GooString *key);
int hash(const char *key);
GBool deleteKeys; // set if key strings should be deleted
......
......@@ -26,6 +26,7 @@
// Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2015 William Bader <williambader@hotmail.com>
// Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -206,7 +207,7 @@ GooString::GooString(const char *sA, int lengthA) {
Set(sA, lengthA);
}
GooString::GooString(GooString *str, int idx, int lengthA) {
GooString::GooString(const GooString *str, int idx, int lengthA) {
s = nullptr;
length = 0;
assert(idx + lengthA <= str->length);
......@@ -268,7 +269,7 @@ GooString *GooString::append(char c) {
return append((const char*)&c, 1);
}
GooString *GooString::append(GooString *str) {
GooString *GooString::append(const GooString *str) {
return append(str->getCString(), str->getLength());
}
......@@ -789,7 +790,7 @@ GooString *GooString::lowerCase() {
return this;
}
int GooString::cmp(GooString *str) const {
int GooString::cmp(const GooString *str) const {
int n1, n2, i, x;
char *p1, *p2;
......
......@@ -23,6 +23,7 @@
// Copyright (C) 2015 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -64,7 +65,7 @@ public:
GooString(const char *sA, int lengthA);
// Create a string from <lengthA> chars at <idx> in <str>.
GooString(GooString *str, int idx, int lengthA);
GooString(const GooString *str, int idx, int lengthA);
// Set content of a string to <newStr>. If <newLen> is CALC_STRING_LEN, then
// length of the string will be calculated with strlen(). Otherwise we assume
......@@ -132,7 +133,7 @@ public:
// Append a character or string.
GooString *append(char c);
GooString *append(GooString *str);
GooString *append(const GooString *str);
GooString *append(const char *str, int lengthA=CALC_STRING_LEN);
// Append a formatted string.
......@@ -152,7 +153,7 @@ public:
GooString *lowerCase();
// Compare two strings: -1:< 0:= +1:>
int cmp(GooString *str) const;
int cmp(const GooString *str) const;
int cmpN(GooString *str, int n) const;
int cmp(const char *sA) const;
int cmpN(const char *sA, int n) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment