[commit: ghc] master: rts/Hash: Constify HashTable* in lookupHashTable (334fe45)
git at git.haskell.org
git at git.haskell.org
Tue Nov 3 22:16:51 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/334fe4500c234e83f250f74679f7bbe20208abba/ghc
>---------------------------------------------------------------
commit 334fe4500c234e83f250f74679f7bbe20208abba
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Tue Nov 3 16:16:27 2015 -0600
rts/Hash: Constify HashTable* in lookupHashTable
This seems like an obvious place to apply `const`
Reviewed By: simonmar, austin
Differential Revision: https://phabricator.haskell.org/D1416
>---------------------------------------------------------------
334fe4500c234e83f250f74679f7bbe20208abba
rts/FileLock.c | 2 +-
rts/Hash.c | 6 +++---
rts/Hash.h | 8 ++++----
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/rts/FileLock.c b/rts/FileLock.c
index cd2dc1d..f8e11ee 100644
--- a/rts/FileLock.c
+++ b/rts/FileLock.c
@@ -41,7 +41,7 @@ static int cmpLocks(StgWord w1, StgWord w2)
return (l1->device == l2->device && l1->inode == l2->inode);
}
-static int hashLock(HashTable *table, StgWord w)
+static int hashLock(const HashTable *table, StgWord w)
{
Lock *l = (Lock *)w;
StgWord key = l->inode ^ (l->inode >> 32) ^ l->device ^ (l->device >> 32);
diff --git a/rts/Hash.c b/rts/Hash.c
index aab3b23..b0939c4 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -58,7 +58,7 @@ struct hashtable {
* -------------------------------------------------------------------------- */
int
-hashWord(HashTable *table, StgWord key)
+hashWord(const HashTable *table, StgWord key)
{
int bucket;
@@ -76,7 +76,7 @@ hashWord(HashTable *table, StgWord key)
}
int
-hashStr(HashTable *table, char *key)
+hashStr(const HashTable *table, char *key)
{
int h, bucket;
char *s;
@@ -187,7 +187,7 @@ expand(HashTable *table)
}
void *
-lookupHashTable(HashTable *table, StgWord key)
+lookupHashTable(const HashTable *table, StgWord key)
{
int bucket;
int segment;
diff --git a/rts/Hash.h b/rts/Hash.h
index 136f94a..c2dfc26 100644
--- a/rts/Hash.h
+++ b/rts/Hash.h
@@ -15,7 +15,7 @@ typedef struct hashtable HashTable; /* abstract */
/* Hash table access where the keys are StgWords */
HashTable * allocHashTable ( void );
-void * lookupHashTable ( HashTable *table, StgWord key );
+void * lookupHashTable ( const HashTable *table, StgWord key );
void insertHashTable ( HashTable *table, StgWord key, void *data );
void * removeHashTable ( HashTable *table, StgWord key, void *data );
@@ -44,11 +44,11 @@ HashTable * allocStrHashTable ( void );
(removeHashTable(table, (StgWord)key, data))
/* Hash tables for arbitrary keys */
-typedef int HashFunction(HashTable *table, StgWord key);
+typedef int HashFunction(const HashTable *table, StgWord key);
typedef int CompareFunction(StgWord key1, StgWord key2);
HashTable * allocHashTable_(HashFunction *hash, CompareFunction *compare);
-int hashWord(HashTable *table, StgWord key);
-int hashStr(HashTable *table, char *key);
+int hashWord(const HashTable *table, StgWord key);
+int hashStr(const HashTable *table, char *key);
/* Freeing hash tables
*/
More information about the ghc-commits
mailing list