SCI: Added TODO: Merge SegInterface and MemObject? And some cleanup
svn-id: r39485
This commit is contained in:
parent
3c23ba7d73
commit
95c58e76d6
4 changed files with 25 additions and 6 deletions
|
@ -70,9 +70,9 @@ int IntMapper::checkKey(int key, bool add, bool *was_added) {
|
|||
if (was_added)
|
||||
*was_added = false;
|
||||
|
||||
if (*node) {
|
||||
if (*node)
|
||||
return (*node)->idx;
|
||||
}
|
||||
|
||||
// Not found
|
||||
|
||||
if (!add)
|
||||
|
@ -96,6 +96,18 @@ int IntMapper::checkKey(int key, bool add, bool *was_added) {
|
|||
return (*node)->idx;
|
||||
}
|
||||
|
||||
int IntMapper::lookupKey(int key) const {
|
||||
Node *const *node = &(nodes[HASH(key)]);
|
||||
|
||||
while (*node && (key != (*node)->key))
|
||||
node = &((*node)->next);
|
||||
|
||||
if (*node)
|
||||
return (*node)->idx;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void IntMapper::saveLoadWithSerializer(Common::Serializer &s) {
|
||||
s.syncAsSint32LE(base_value);
|
||||
if (s.isLoading()) {
|
||||
|
|
|
@ -93,6 +93,9 @@ public:
|
|||
*/
|
||||
int checkKey(int key, bool add, bool *wasAdded = 0);
|
||||
|
||||
int lookupKey(int key) const;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a key from the map.
|
||||
* @param key The key to remove
|
||||
|
|
|
@ -568,8 +568,8 @@ void SegManager::sm_put_heap(reg_t reg, int16 value) {
|
|||
#endif
|
||||
|
||||
// return the seg if script_id is valid and in the map, else -1
|
||||
int SegManager::segGet(int script_id) {
|
||||
return id_seg_map->checkKey(script_id, false);
|
||||
int SegManager::segGet(int script_id) const {
|
||||
return id_seg_map->lookupKey(script_id);
|
||||
}
|
||||
|
||||
// validate the seg
|
||||
|
|
|
@ -103,8 +103,7 @@ public:
|
|||
// Get the segment ID associated with a script number
|
||||
// Parameters: (int) script_nr: Number of the script to look up
|
||||
// Returns : (int) The associated segment ID, or -1 if no matching segment exists
|
||||
// This function is "pure" (i.e, it doesn't modify anything).
|
||||
int segGet(int script_nr);
|
||||
int segGet(int script_nr) const;
|
||||
|
||||
|
||||
// script lock operations
|
||||
|
@ -445,6 +444,11 @@ private:
|
|||
|
||||
// 11. Segment interface, primarily for GC
|
||||
|
||||
// TODO: Merge SegInterface and MemObject?
|
||||
// After all, _mobj->type == _typeId
|
||||
// and we make very little use of _segmgr (-> could get rid of that).
|
||||
// Other code would benefit, e.g. the saveload code.
|
||||
// But note that _mobj->segmgr_id != _segId !
|
||||
class SegInterface {
|
||||
protected:
|
||||
SegInterface(SegManager *segmgr, MemObject *mobj, SegmentId segId, memObjType typeId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue