Skip to content

Commit

Permalink
include several fixes proposed by Lauri
Browse files Browse the repository at this point in the history
- thanks for the feedback!
  • Loading branch information
Arnaud Bouchez committed Jan 6, 2021
1 parent 8f0c8ba commit bf270ae
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 131 deletions.
2 changes: 1 addition & 1 deletion src/core/mormot.core.interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3448,7 +3448,7 @@ class function TInterfaceFactory.Get(const aInterfaceName: RawUtf8): TInterfaceF
try
F := pointer(InterfaceFactoryCache.List);
for i := 1 to InterfaceFactoryCache.Count do
if IdemPropName(F^.fInterfaceName, pointer(aInterfaceName), L) then
if IdemPropNameU(F^.fInterfaceName, pointer(aInterfaceName), L) then
begin
result := F^;
exit; // retrieved from cache
Expand Down
10 changes: 2 additions & 8 deletions src/core/mormot.core.search.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2816,7 +2816,7 @@ constructor TMatchs.Create(const aPatterns: TRawUtf8DynArray; CaseInsensitive: b

function TMatchs.Match(const aText: RawUtf8): integer;
begin
result := match(pointer(aText), length(aText));
result := Match(pointer(aText), length(aText));
end;

function TMatchs.Match(aText: PUtf8Char; aLen: integer): integer;
Expand Down Expand Up @@ -2855,13 +2855,7 @@ function TMatchs.MatchString(const aText: string): integer;
temp: TSynTempBuffer;
len: integer;
begin
len := length(aText);
temp.Init(len * 3);
{$ifdef UNICODE}
len := RawUnicodeToUtf8(temp.buf, temp.len + 1, pointer(aText), len, [ccfNoTrailingZero]);
{$else}
len := CurrentAnsiConvert.AnsiBufferToUtf8(temp.buf, pointer(aText), len, true) - temp.buf;
{$endif UNICODE}
len := StringToUtf8(aText, temp);
result := match(temp.buf, len);
temp.Done;
end;
Expand Down
16 changes: 8 additions & 8 deletions src/core/mormot.core.unicode.pas
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ function ToUtf8(const Text: string): RawUtf8; overload;
// - this overloaded function use a TSynTempBuffer for the result to avoid any
// memory allocation for the shorter content
// - caller should call u.Done to release any heap-allocated memory
function StringToUtf8(const Text: string; var u: TSynTempBuffer): integer; overload;
function StringToUtf8(const Text: string; var Temp: TSynTempBuffer): integer; overload;

/// convert any UTF-8 encoded shortstring Text into an UTF-8 encoded String
// - expects the supplied content to be already ASCII-7 or UTF-8 encoded, e.g.
Expand Down Expand Up @@ -3503,13 +3503,13 @@ procedure StringToUtf8(const Text: string; var result: RawUtf8);
RawUnicodeToUtf8(pointer(Text), Length(Text), result);
end;

function StringToUtf8(const Text: string; var u: TSynTempBuffer): integer;
function StringToUtf8(const Text: string; var Temp: TSynTempBuffer): integer;
var
len: integer;
begin
len := length(Text);
u.Init(len * 3);
result := RawUnicodeToUtf8(u.buf, u.len + 1, pointer(Text), len, []);
Temp.Init(len * 3);
result := RawUnicodeToUtf8(Temp.buf, Temp.len + 1, pointer(Text), len, []);
end;

function ToUtf8(const Text: string): RawUtf8;
Expand Down Expand Up @@ -3625,14 +3625,14 @@ procedure StringToUtf8(const Text: string; var result: RawUtf8);
result := CurrentAnsiConvert.AnsiToUtf8(Text);
end;

function StringToUtf8(const Text: string; var u: TSynTempBuffer): integer;
function StringToUtf8(const Text: string; var Temp: TSynTempBuffer): integer;
var
len: integer;
begin
len := length(Text);
u.Init(len * 3);
result := CurrentAnsiConvert.AnsiBufferToUtf8(u.buf, pointer(Text), len)
- PUtf8Char(u.buf);
Temp.Init(len * 3);
result := CurrentAnsiConvert.AnsiBufferToUtf8(Temp.buf, pointer(Text), len)
- PUtf8Char(Temp.buf);
end;

function ToUtf8(const Text: string): RawUtf8;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mormot.lib.winhttp.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ procedure HttpApiInitialize;
exit; // already loaded
mormot.core.os.GlobalLock;
try
if Http.Module <> 0 then
if Http.Module = 0 then
try
Http.Module := LoadLibrary(HTTPAPI_DLL);
Http.Version.MajorVersion := 2; // API 2.0 if all functions are available
Expand Down
26 changes: 26 additions & 0 deletions src/mormot.defines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,29 @@
// enable https://curl.haxx.se/libcurl/c/libcurl-multi.html interface
{$endif USELIBCURL}

{$ifndef NOCOMPRESSSYNLZ}
{$define COMPRESSSYNLZ}
{ if defined, mormot.rest.http.server will use SynLZ for content compression
- SynLZ is much faster than deflate/zip, so is preferred
- can be set global for Client and Server applications
- with SynLZ, the 440 KB JSON for TTestClientServerAccess._TRestHttpClient
is compressed into 106 KB with no speed penalty (it's even a bit faster)
whereas deflate, even with its level set to 1 (fastest), is 25 % slower
- TRestHttpClientGeneric.Compression shall contain hcSynLZ to handle it }
{$endif NOCOMPRESSSYNLZ}


{$ifndef NOCOMPRESSDEFLATE}
{$define COMPRESSDEFLATE}
{ if defined, mormot.rest.http.server will use gzip for content compression
- can be set global for Client and Server applications
- deflate/zip is just broken between browsers and client, and should be
avoided: see http://stackoverflow.com/a/9186091
- SynLZ is faster but only known by Delphi clients: you can enable deflate
when the server is connected an AJAX application (not defined by default)
- if you define both COMPRESSSYNLZ and COMPRESSDEFLATE, the server will use
SynLZ if available, and deflate if not called from a Delphi client
- TRestHttpClientGeneric.Compression shall contain hcDeflate to handle it }
{$endif NOCOMPRESSDEFLATE}


6 changes: 3 additions & 3 deletions src/net/mormot.net.http.pas
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ THttpServerRequestAbstract = class;
THttpServerRequestAbstract = class
protected
fRemoteIP,
fURL,
fUrl,
fMethod,
fInHeaders,
fInContentType,
Expand All @@ -301,8 +301,8 @@ THttpServerRequestAbstract = class
/// append some lines to the InHeaders input parameter
procedure AddInHeader(additionalHeader: RawUtf8);
/// input parameter containing the caller URI
property URL: RawUtf8
read fURL;
property Url: RawUtf8
read fUrl;
/// input parameter containing the caller method (GET/POST...)
property Method: RawUtf8
read fMethod;
Expand Down
2 changes: 1 addition & 1 deletion src/orm/mormot.orm.core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18031,7 +18031,7 @@ function TOrm.FillPrepareMany(const aClient: IRestOrm;
end;
{ assert(T.FieldCount=SqlFieldsCount);
for i := 0 to SqlFieldsCount-1 do
assert(IdemPropName(SqlFields[i].SQL,T.fResults[i],StrLen(T.fResults[i]))); }
assert(IdemPropNameU(SqlFields[i].SQL,T.fResults[i],StrLen(T.fResults[i]))); }
fFill.fTable := T;
T.OwnerMustFree := true;
fFill.fFillCurrentRow := 1; // point to first data row (0 is field names)
Expand Down
1 change: 1 addition & 0 deletions src/orm/mormot.orm.rest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,7 @@ function TRestOrm.AsynchBatchStart(Table: TOrmClass;
function TRestOrm.AsynchBatchStop(Table: TOrmClass): boolean;
begin
if (self = nil) or
(fRest.Run = nil) or
(fRest.Run.BackgroundTimer = nil) or
(fRest.Run.BackgroundTimer.BackgroundBatch = nil) then
result := false
Expand Down

0 comments on commit bf270ae

Please sign in to comment.