Perf shortcut for PwUuid comparison. Don't write out Zero PwUuid's for custom icons (use null instead)

This commit is contained in:
AlexVallat 2013-07-13 09:20:48 +01:00
parent bf84662857
commit 9f01e834d0
2 changed files with 10 additions and 4 deletions

View File

@ -112,6 +112,12 @@ namespace KeePassLib
Debug.Assert(uuid != null);
if(uuid == null) throw new ArgumentNullException("uuid");
// Shortcut
if (Object.ReferenceEquals(this, uuid))
{
return true;
}
for(int i = 0; i < UuidSize; ++i)
{
if(m_pbUuid[i] != uuid.m_pbUuid[i]) return false;

View File

@ -584,8 +584,8 @@ namespace KeePassLib.Serialization
[ProtoMember(5, OverwriteList = true)]
public byte[] CustomIconUuid
{
get { return mGroup.CustomIconUuid.UuidBytes; }
set { mGroup.CustomIconUuid = new PwUuid(value); }
get { return mGroup.CustomIconUuid.EqualsValue(PwUuid.Zero) ? null : mGroup.CustomIconUuid.UuidBytes; ; }
set { mGroup.CustomIconUuid = value == null ? PwUuid.Zero : new PwUuid(value); }
}
[ProtoMember(6)]
@ -858,8 +858,8 @@ namespace KeePassLib.Serialization
[ProtoMember(3, OverwriteList = true)]
public byte[] CustomIconUuid
{
get { return mEntry.CustomIconUuid.UuidBytes; }
set { mEntry.CustomIconUuid = new PwUuid(value); }
get { return mEntry.CustomIconUuid.EqualsValue(PwUuid.Zero) ? null : mEntry.CustomIconUuid.UuidBytes; }
set { mEntry.CustomIconUuid = value == null ? PwUuid.Zero : new PwUuid(value); }
}
[ProtoMember(4)]