[Scummvm-devel] PS2 #9 : performance : node optimization : important

Willem Jan Palenstijn wjp at usecode.org
Mon Mar 2 10:36:23 CET 2009


On Mon, Mar 02, 2009 at 07:00:55AM +0100, sunmax at libero.it wrote:
> At the moment we have a set of bools "isDir", "isValid" flags.
> + methods and maybe even couple more platform specific flags
> (eg. "isDev", "isRoot") that could be set at node creation
> without need to check them over and over. To do this it would
> be useful if we could have a "uint32 flags" in FSNode where
> each bit has a defined meaning. Some as "isDir", "isValid" bits
> would be universal, shared between all platforms, a chunk of
> this uint32 flags would then be reserved for the backends.

I don't think mixing general and backend-specific flags in a single
field is a good idea, because it exposes backend-specifics to engines,
and also forces a specific way of caching these values on the backends.

If you want to cache flags (like the general dir/read/write flags and
the _IS_DEV you mention below) in a flag field, you can of course still
do so in Ps2FSNode itself.

-Willem Jan




> So instead of having a isDir(), isValid(), etc list of methods.
> we would just have a getFlags() where we can check the bits
> with a binary AND. eg. if (node.getFlags() & _IS_DIR) ...
> 
> Maybe it's not the best solution, but I am just thinking of
> some general way to get/set flags without polluting the API
> and that can be shared between base class and derived ones.
> 
> Eg. on PS2 I could then do (node.getFlags() & _IS_DEV) using
> the pool of bits reserved to backends, instead of having to
> check every time with a strncmp if it's mc, usb, hd, etc.
> 
> Any other alternative is welcome.




More information about the Scummvm-devel mailing list