Skip to content

Commit d220ec1

Browse files
committed
small optimization
1 parent f887730 commit d220ec1

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

hslib.pas

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,14 @@ function validUTF8(s:rawbytestring):boolean;
527527
continue;
528528
if c >= $FE then
529529
exit(FALSE);
530-
if c >= $F0 then more:=3
531-
else if c >= $E0 then more:=2
532-
else if c >= $C0 then more:=1
533-
else exit(FALSE);
530+
if c >= $F0 then
531+
more:=3
532+
else if c >= $E0 then
533+
more:=2
534+
else if c >= $C0 then
535+
more:=1
536+
else
537+
exit(FALSE);
534538
if i+more > len then
535539
exit(FALSE);
536540
while more > 0 do

main.pas

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,22 +4624,26 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
46244624
procedure doLog();
46254625
var
46264626
i: integer;
4627-
url_: string; // an alias, final '_' is to not confuse with the other var
46284627
s: string;
4628+
4629+
function decodedUrl():string;
4630+
begin
4631+
if conn = NIL then
4632+
exit('');
4633+
result:=decodeURL(conn.request.url);
4634+
end;
4635+
46294636
begin
46304637
if assigned(data) and data.dontLog and (event <> HE_DISCONNECTED) then exit; // we exit expect for HE_DISCONNECTED because dontLog is always set AFTER connections, so HE_CONNECTED is always logged. The coupled HE_DISCONNECTED should be then logged too.
46314638

46324639
if assigned(data) and (data.preReply = PR_BAN)
46334640
and not logBannedChk.checked then exit;
46344641

4635-
if conn = NIL then url_:=''
4636-
else url_:=decodeURL(conn.request.url);
46374642
if not (event in [HE_OPEN, HE_CLOSE, HE_CONNECTED, HE_DISCONNECTED, HE_GOT]) then
46384643
if not logIconsChk.checked and (data.downloadingWhat = DW_ICON)
46394644
or not logBrowsingChk.checked and (data.downloadingWhat = DW_FOLDERPAGE)
4640-
or not logProgressChk.checked and (url_ = '/~progress') then
4645+
or not logProgressChk.checked and (decodedUrl() = '/~progress') then
46414646
exit;
4642-
46434647
if not (event in [HE_OPEN, HE_CLOSE])
46444648
and addressMatch(dontLogAddressMask, data.address) then
46454649
exit;
@@ -4693,7 +4697,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
46934697
s:=subStr(conn.getHeader('Range'), 7);
46944698
if s > '' then
46954699
s:=TAB+'['+s+']';
4696-
add2log(format('Requested %s %s%s', [ METHOD2STR[conn.request.method], url_, s ]), data);
4700+
add2log(format('Requested %s %s%s', [ METHOD2STR[conn.request.method], decodedUrl(), s ]), data);
46974701
end;
46984702
if dumprequestsChk.checked then
46994703
add2log('Request dump'+CRLF+conn.request.full, data);
@@ -4730,7 +4734,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
47304734
add2log(format('Fully downloaded - %s @ %sB/s - %s', [
47314735
smartSize(conn.bytesSentLastItem),
47324736
smartSize(calcAverageSpeed(conn.bytesSentLastItem)),
4733-
url_]), data);
4737+
decodedUrl()]), data);
47344738
end;
47354739
end;
47364740

0 commit comments

Comments
 (0)