aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMax Horn2010-07-01 16:05:47 +0000
committerMax Horn2010-07-01 16:05:47 +0000
commit9d47b191f6302ac8960bb4d91d32104c0993a198 (patch)
treee0e8524e68cde7d4be66be175bf865a4c60ee57e /engines/sci/engine
parentb8904a48ed81d04a2cbe84f78d80aaa75344d16e (diff)
downloadscummvm-rg350-9d47b191f6302ac8960bb4d91d32104c0993a198.tar.gz
scummvm-rg350-9d47b191f6302ac8960bb4d91d32104c0993a198.tar.bz2
scummvm-rg350-9d47b191f6302ac8960bb4d91d32104c0993a198.zip
SCI: Rename some more stuff
svn-id: r50553
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/gc.cpp14
-rw-r--r--engines/sci/engine/gc.h9
2 files changed, 12 insertions, 11 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp
index 75456bcef0..936b83d760 100644
--- a/engines/sci/engine/gc.cpp
+++ b/engines/sci/engine/gc.cpp
@@ -30,7 +30,7 @@ namespace Sci {
struct WorklistManager {
Common::Array<reg_t> _worklist;
- reg_t_hash_map _map;
+ AddrSet _map;
void push(reg_t reg) {
if (!reg.segment) // No numbers
@@ -51,10 +51,10 @@ struct WorklistManager {
}
};
-static reg_t_hash_map *normalizeAddresses(SegManager *segMan, reg_t_hash_map &nonnormal_map) {
- reg_t_hash_map *normal_map = new reg_t_hash_map();
+static AddrSet *normalizeAddresses(SegManager *segMan, const AddrSet &nonnormal_map) {
+ AddrSet *normal_map = new AddrSet();
- for (reg_t_hash_map::iterator i = nonnormal_map.begin(); i != nonnormal_map.end(); ++i) {
+ for (AddrSet::const_iterator i = nonnormal_map.begin(); i != nonnormal_map.end(); ++i) {
reg_t reg = i->_key;
SegmentObj *mobj = segMan->getSegmentObj(reg.segment);
@@ -68,9 +68,9 @@ static reg_t_hash_map *normalizeAddresses(SegManager *segMan, reg_t_hash_map &no
}
-reg_t_hash_map *find_all_used_references(EngineState *s) {
+AddrSet *findAllActiveReferences(EngineState *s) {
SegManager *segMan = s->_segMan;
- reg_t_hash_map *normal_map = NULL;
+ AddrSet *normal_map = NULL;
WorklistManager wm;
uint i;
@@ -159,7 +159,7 @@ void run_gc(EngineState *s) {
memset(segcount, 0, sizeof(segcount));
// Compute the set of all segments references currently in use.
- reg_t_hash_map *activeRefs = find_all_used_references(s);
+ AddrSet *activeRefs = findAllActiveReferences(s);
// Iterate over all segments, and check for each whether it
// contains stuff that can be collected.
diff --git a/engines/sci/engine/gc.h b/engines/sci/engine/gc.h
index cfae517790..f4318a1453 100644
--- a/engines/sci/engine/gc.h
+++ b/engines/sci/engine/gc.h
@@ -35,21 +35,22 @@ namespace Sci {
struct reg_t_Hash {
uint operator()(const reg_t& x) const {
- return (x.segment << 3) | x.offset;
+ return (x.segment << 3) ^ x.offset ^ (x.offset << 16);
}
};
/*
- * The reg_t_hash_map is actually really a hashset
+ * The AddrSet is a "set" of reg_t values.
+ * We don't have a HashSet type, so we abuse a HashMap for this.
*/
-typedef Common::HashMap<reg_t, bool, reg_t_Hash> reg_t_hash_map;
+typedef Common::HashMap<reg_t, bool, reg_t_Hash> AddrSet;
/**
* Finds all used references and normalises them to their memory addresses
* @param s The state to gather all information from
* @return A hash map containing entries for all used references
*/
-reg_t_hash_map *find_all_used_references(EngineState *s);
+AddrSet *findAllActiveReferences(EngineState *s);
/**
* Runs garbage collection on the current system state