Opened 16 years ago

Closed 16 years ago

Last modified 5 years ago

#8931 closed patch

SearchSet: Get rid of SharedPtr usage

Reported by: lordhoto Owned by: lordhoto
Priority: normal Component: --Other--
Version: Keywords:
Cc: Game:

Description

Hi,

this patch removes the ArchivePtr parameter in SearchSet::add and replaces it with a plain pointer + bool variable which indicates if the given pointer should be freed on deletion. The 'autoFree' flag is true on default. We might want to check about this.

One of the reasons for that change is that now I'm able to add SearchMan to my own SearchSet in KYRA (Fixes bug #2103506 "KYRA: Kyra.dat is not search in all dirs anymore"). Also some code in PARALLACTION is now simplified, instead of first creating a ArchivePtr and then passing it to SearchSet::add, now PARALLACTION can simply use "_sset.add("part", _baseDir->getSubDirectory(name, 3), 10);". It might help in other cases too. So all in all it should get rid of the overhead of SharedPtr in this case and ease use of own SearchSet in conjunction with SearchMan.

Ticket imported from: #2184529. Ticket imported from: patches/1036.

Attachments (2)

archive_ptr_v1.patch (16.9 KB ) - added by lordhoto 16 years ago.
Patch against r34831.
archive_ptr_v1.1.patch (16.9 KB ) - added by lordhoto 16 years ago.
Patch against r34831.

Download all attachments as: .zip

Change History (9)

by lordhoto, 16 years ago

Attachment: archive_ptr_v1.patch added

Patch against r34831.

comment:1 by lordhoto, 16 years ago

Updated the patch with a fix in the kyra related changes.

by lordhoto, 16 years ago

Attachment: archive_ptr_v1.1.patch added

Patch against r34831.

comment:2 by peres, 16 years ago

Nothing against this change. I think I will have to learn when to use this SharedPtr thing ;)

Let's see if there are other opinions :)

comment:3 by fingolfin, 16 years ago

Grrr, stupid SF.net just ate my comment *sigh*

Anyway, here it goes once more: I don't mind this patch being applied, I think I even suggested something along these lines in the past.

An alternative approach would be to change the Singleton class to use an ArchivePtr internally, then expose that ArchivePtr via some new Singleton API. That way, one could keep using ArchivePtrs, which at times is handy.

However, I am not convinced that this is such a good idea. And *not* using ArchivePtr of course saves us some overhead, and will help (a tiny bit) all ports with low memory & slow CPUs.

comment:4 by lordhoto, 16 years ago

Yes we talked about that change, though I didn't hear peres official opinion on that. Anyway since you both agree I'll just commit it.

comment:5 by lordhoto, 16 years ago

Owner: changed from peres to lordhoto
Status: newclosed
Summary: SearchSet: Get rid of SharedPtr usage"

comment:6 by lordhoto, 16 years ago

Summary: "SearchSet: Get rid of SharedPtr usage

comment:7 by digitall, 5 years ago

Component: --Other--
Note: See TracTickets for help on using tickets.