Project

General

Profile

Actions

Emulator Issues #2711

closed

IniFile code replacement

Added by Billiard26 almost 14 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

I have replaced Dolphin's IniFile code with the IniFile code used by the
New GCPad and Wiimote plugins.

The proposed IniFile is a class which inherits:
map< string, map< string, string > >
along with additional Get/Set/Load/Save... methods like the current inifile
code.

// Because IniFile and Sections inherit std::map, values can be accessed
like so:

inifile["section_name"]["key_name"] = "value";
some_string = inifile["section_name"]["key_name"];

// Get/Set can still be used:
// Get/Set methods are of the Section class now, rather than the IniFile class

inifile["section_name"].Get("key_name", &some_int, 5);
// very similar to the current syntax
//inifile.Get("section_name", "key_name", &some_int, 5);

// current code:

//iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
//iniFile.Set("Real", "AccNeutralY", iAccNeutralY);
//iniFile.Set("Real", "AccNeutralZ", iAccNeutralZ);

// this can be(it is in the patch) replaced with:

Section& real = iniFile["Real"];
real.Set("AccNeutralX", iAccNeutralX);
real.Set("AccNeutralY", iAccNeutralY);
real.Set("AccNeutralZ", iAccNeutralZ);

// ...a reference to the section "Real" can be created
// so searching the inifile for the same section (sometimes 15+ times) is
not needed

Patch: http://billiard.us.to/share/Dolphin/inifile_replacement.patch

Pros:

  • Less code to maintain
    Current: IniFile.cpp 526 lines, IniFile.h 92 lines
    Proposed: IniFile.cpp 255 lines, IniFile.h 123 lines
    templates are used for Get()/Set() methods
    extra code to find sections/keys is not needed, because of inheriting
    std::map methods

  • Performance
    http://pastie.org/954684
    Get()/Set() methods are 90x faster!

Cons:

  • Comments are completely ignored and Removed from an inifile after saving

  • GetLines()/SetLines() functionality is somewhat hacked in.
    After {Get,Set}Lines is called on a Section, the normal Get/Set
    functions will have no effect on the saved file.
    These functions are used to access non-inifile syntax lines for AR codes
    in the game ini files.
    These lines don't belong in inifiles anyway.

  • Bigger file sizes
    Dolphin.exe +30KB
    Plugin_DSP_HLE +60KB
    Plugin_GCPad.dll +80KB
    Plugin_Wiimote.dll +90KB
    etc...

Pro/Con:
Being a std::map, saved files automatically have alphabetized sections
and keys.
Mostly good, but someone might not like this.

I want to know if anyone opposes the changes, or if I should commit them.
Thanks

Actions

Also available in: Atom PDF