diff options
author | George Hazan <ghazan@miranda.im> | 2018-10-08 13:56:32 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-10-08 13:56:32 +0300 |
commit | 0fac9e9fd54aecd1a712c85ddde1b84306cfe5a1 (patch) | |
tree | 0bdb1fb1985d3f7056b0d7ed3a951ced308b6815 | |
parent | a9657437f9007340842330f87c262f90b65fab9c (diff) |
code cleaning
-rw-r--r-- | include/m_database.h | 18 | ||||
-rw-r--r-- | plugins/Import/src/utils.cpp | 14 |
2 files changed, 14 insertions, 18 deletions
diff --git a/include/m_database.h b/include/m_database.h index fd861c5036..b85aee92e9 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -139,7 +139,7 @@ EXTERN_C MIR_CORE_DLL(int) db_enum_settings(MCONTACT hContact, DBSETTINGENUMPROC #define DBVTF_VARIABLELENGTH 0x80
-typedef struct
+struct DBVARIANT
{
BYTE type;
union {
@@ -158,7 +158,7 @@ typedef struct BYTE *pbVal;
};
};
-} DBVARIANT;
+};
#define DBEF_SENT 2 // this event was sent by the user. If not set this event was received.
#define DBEF_READ 4 // event has been read by the user. It does not need to be processed any more except for history.
@@ -166,12 +166,12 @@ typedef struct #define DBEF_UTF 16 // event contains a text in utf-8
#define DBEF_ENCRYPTED 32 // event is encrypted (never reported outside a driver)
-typedef struct
+struct DBEVENTINFO
{
char *szModule; // pointer to name of the module that 'owns' this event
DWORD timestamp; // seconds since 00:00, 01/01/1970. Gives us times until 2106
- // unless you use the standard C library which is
- // signed and can only do until 2038. In GMT.
+ // unless you use the standard C library which is
+ // signed and can only do until 2038. In GMT.
DWORD flags; // the omnipresent flags
WORD eventType; // module-defined event type field
DWORD cbBlob; // size of pBlob in bytes
@@ -188,8 +188,12 @@ typedef struct return (flags & DBEF_UTF) ? mir_utf8decodeW(str) : mir_a2u(str);
}
-#endif
-} DBEVENTINFO;
+ bool __forceinline operator==(const DBEVENTINFO &e)
+ {
+ return (timestamp == e.timestamp && eventType == e.eventType && cbBlob == e.cbBlob && (flags & DBEF_SENT) == (e.flags & DBEF_SENT));
+ }
+ #endif
+};
EXTERN_C MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv);
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index 7ae0567580..ab2cd0a3e6 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -48,14 +48,6 @@ int CreateGroup(const wchar_t *group, MCONTACT hContact) return 1;
}
-static bool IsEqualEvent(const DBEVENTINFO &ev1, const DBEVENTINFO &ev2)
-{
- return (ev1.timestamp == ev2.timestamp &&
- ev1.eventType == ev2.eventType &&
- ev1.cbBlob == ev2.cbBlob &&
- (ev1.flags & DBEF_SENT) == (ev2.flags & DBEF_SENT));
-}
-
// Returns TRUE if the event already exist in the database
bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei)
{
@@ -109,7 +101,7 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) memset(&dbeiExisting, 0, sizeof(dbeiExisting));
db_event_get(hPreviousDbEvent, &dbeiExisting);
- if (IsEqualEvent(dbei, dbeiExisting))
+ if (dbei == dbeiExisting)
return TRUE;
// find event with another timestamp
@@ -146,7 +138,7 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) }
// Compare event with import candidate
- if (IsEqualEvent(dbei, dbeiExisting)) {
+ if (dbei == dbeiExisting) {
// remember event
hPreviousDbEvent = hExistingDbEvent;
dwPreviousTimeStamp = dbeiExisting.timestamp;
@@ -171,7 +163,7 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) }
// Compare event with import candidate
- if (IsEqualEvent(dbei, dbeiExisting)) {
+ if (dbei == dbeiExisting) {
// remember event
hPreviousDbEvent = hExistingDbEvent;
dwPreviousTimeStamp = dbeiExisting.timestamp;
|