OSDN Git Service

文字列比較や文字列コピーを減らしてさらに高速化、一般的なスクリプトで元々の約2.3倍
[winbottle/winbottle.git] / bottleclient / Logs.pas
index c07b840..037c538 100755 (executable)
@@ -59,7 +59,7 @@ type
 
   EXMLFileOpenException = class(Exception);
 
-  TBottleLogDownLoadCondition = packed record
+  TBottleLogDownloadCondition = packed record
     IsRange: boolean;
     RecentCount: integer;
     DateLo: TDateTime;
@@ -112,6 +112,7 @@ type
     FOldSortColumn: TBottleLogSortType; // \83\8d\83O\91\8b
     FOldSortDesc: boolean;   // \83\8d\83O\91\8b
     FSelectedIndex: integer;
+    FLastDownloadCondition: TBottleLogDownloadCondition;
     FOnLoadWork: TNotifyEvent; // \83\8d\83O\91\8b
     FImagePath: String; // HTML\8fo\97Í\8e\9e\82ÌIMG\83^\83O\82Ì\83p\83X(\91\8a\91Î\82Ü\82½\82Í\90â\91Î\83p\83X)
     FImageFiles: TStringList;
@@ -447,6 +448,8 @@ end;
 
 procedure TBottleLogList.LoadFromStream(Stream: TStream);
 var i: integer;
+    agree: integer;
+    vote: integer;
     SourceStream: TStringStream;
     Source: TStringList;
     LogItem: TLogItem;
@@ -475,13 +478,24 @@ begin
       end;
       Self.Clear;
       while (i + 7) < Source.Count do begin
-        LogItem := TLogItem.Create(ltBottle, Source[i+1], Source[i+2],
-          Source[i+7], Source[i+3], S2D(Source[i]));
-        LogItem.Votes  := StrToInt(Source[i+5]);
-        LogItem.Agrees := StrToInt(Source[i+6]);
-        LogItem.State := lsOpened;
+        vote := StrToInt(Source[i+5]);
+        agree := StrToInt(Source[i+6]);
+
+        //\93\8a\95[\81E\93¯\88Ó\8fð\8c\8f\8ew\92è\82Í\82±\82±\82Å\8eÀ\8c»
+        //FIXME FIXME - \97Í\8bZ\82·\82¬\82Ü\82·\81A\81A\81A
+        if vote >= FLastDownloadCondition.MinVote then begin
+          if agree >= FLastDownloadCondition.MinAgree then begin
+            LogItem := TLogItem.Create(ltBottle, Source[i+1], Source[i+2],
+              Source[i+7], Source[i+3], S2D(Source[i]));
+
+            LogItem.Votes  := vote;
+            LogItem.Agrees := agree;
+            LogItem.State  := lsOpened;
+            Self.Add(LogItem);
+          end;
+        end;
+
         i := i + 8;
-        Self.Add(LogItem);
       end;
     finally
       SourceStream.Free;
@@ -503,6 +517,8 @@ var Param: String;
 begin
   Self.Clear;
   AddSystemLog('\83_\83E\83\93\83\8d\81[\83h\92\86\82Å\82· - \83T\81[\83o\82©\82ç\89\9e\93\9a\91Ò\82¿');
+
+  FLastDownloadCondition := Cond;
   with Cond do begin
     if Cond.IsRange then begin
       Param := Format('year_lo=%d&month_lo=%d&day_lo=%d&year_hi=%d&month_hi=%d&day_hi=%d&',
@@ -511,13 +527,17 @@ begin
     end else begin
       Param := Format('recent=%d&', [RecentCount]);
     end;
-    Param := Param + Format('minvote=%d&minagree=%d&channel=%s&sort=timedesc&delimiter=%%0D%%0A',
-      [MinVote, MinAgree, ParamsEncode(Channel)]);
+    Param := Param + Format('channel=%s&sort=timedesc&delimiter=%%0D%%0A',
+      [ParamsEncode(Channel)]);
   end;
   FHttpThread := THTTPDownloadThread.Create(Pref.BottleServer, Pref.CgiFetchLog, Param);
   if Pref.UseHttpProxy then begin
     FHttpThread.ProxyServer := Pref.ProxyAddress;
     FHttpThread.ProxyPort   := Pref.ProxyPort;
+    if Pref.ProxyNeedAuthentication then begin
+      FHttpThread.ProxyUser := Pref.ProxyUser;
+      FHttpThread.ProxyPass := Pref.ProxyPass;
+    end;
   end;
   FHttpThread.FreeOnTerminate := true;
   FHttpThread.OnSuccess := HttpSuccess;