Update of /cvsroot/mahogany/M/src/modules/spam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19558/src/modules/spam

Modified Files:
        DspamFilter.cpp 
Log Message:
speed up dspam database operations by using synchronous = off SQlite pragma

Index: DspamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/spam/DspamFilter.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -u -2 -r1.13 -r1.14
--- DspamFilter.cpp     24 Oct 2004 00:26:54 -0000      1.13
+++ DspamFilter.cpp     28 Oct 2004 20:27:22 -0000      1.14
@@ -50,4 +50,25 @@
 {
 public:
+   // create the context
+   DspamCtx(int mode, unsigned flags)
+   {
+      m_ctx = dspam_create
+              (
+                  "mahogany", // user
+                  NULL,       // no group
+                  mApplication->GetLocalDir().ToAscii(),
+                  mode,
+                  flags
+              );
+
+      // this is unsafe as it means that the database could become corrupted if
+      // the system crashes at a bad moment but it is about 10 times faster
+      // than the default "synchronous = NORMAL" so well worth it for non
+      // critical data such as spam database
+      dspam_addattribute(m_ctx, "SQLitePragma", "synchronous = OFF");
+
+      dspam_attach(m_ctx, NULL);
+   }
+
    // destroy the context
    ~DspamCtx()
@@ -62,17 +83,4 @@
    DSPAM_CTX *operator->() const { return m_ctx; }
 
-protected:
-   // take ownership of the specified context
-   DspamCtx(DSPAM_CTX *ctx) : m_ctx(ctx) { }
-
-   // currently we always use the same user name...
-   static const char *GetUser() { return "mahogany"; }
-
-   // return the base dir for dspam files
-   static wxCharBuffer GetHome()
-   {
-      return mApplication->GetLocalDir().ToAscii();
-   }
-
 private:
    DSPAM_CTX *m_ctx;
@@ -86,14 +94,5 @@
 public:
    DspamProcessCtx()
-      :  DspamCtx(dspam_init
-                  (
-                     GetUser(),
-                     NULL,             // no group
-                     GetHome(),
-                     DSM_PROCESS,
-                     DSF_CHAINED |
-                     DSF_NOISE |
-                     DSF_WHITELIST
-                  ))
+      :  DspamCtx(DSM_PROCESS, DSF_CHAINED | DSF_NOISE | DSF_WHITELIST)
    {
    }
@@ -107,5 +106,5 @@
 public:
    DspamClassifyCtx()
-      : DspamCtx(dspam_init(GetUser(), NULL, GetHome(), DSM_CLASSIFY, 0))
+      : DspamCtx(DSM_CLASSIFY, 0)
    {
    }



-------------------------------------------------------
This Newsletter Sponsored by: Macrovision 
For reliable Linux application installations, use the industry's leading
setup authoring tool, InstallShield X. Learn more and evaluate 
today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to