Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/14/22 in all areas

  1. Stefan Glienke

    Array size 64bits

    The difference in performance is clear - accessing a dynamic array which is a field inside the class is two indirections while accessing a static array which is a field inside the class is only one indirection. If you inspect the generated assembly code you will see that every access to the dynamic array has more instructions. This is the case every time you have repeated access to a field inside a method because the compiler does not store it away as if it was a local variable and then directly reads it but basically does Self.Table every time. For this exact reason I have explicitly written code that first reads the dynamic array into a local pointer variable (to avoid the extra reference counting) and then operate on that one via hardcast back to dynamic array (or via pointermath). That way the compiler could keep that in a register and directly index into it rather than dereferencing Self every time to read that dynamic array. To try out, add this code to your Button1Click: {$POINTERMATH ON} Table: ^DWord; {$POINTERMATH OFF} begin SetLength(Self.Table, NbPrime); Table := @Self.Table[0]; Now the code accesses the local Table variable which most likely is stored in a register.
  2. Fr0sT.Brutal

    Firebird 4, FireDAC and D11.2

    Time with TZ is independent from any system settings
  3. FPiette

    custom fonts and sizes showmessage()

    Why not create your own ShowMessage function? After all it is simply a modal form that you can easily build yourself to fit your needs.
  4. Technically, it is possible to recognise a non-SSL connection is being made to an SSL port, OpenSSL specifically checks if an HTTP header is being received rather than a HELLO packet and raises an error. And hackers often do this, attempting to made non-SSL connections to port 443, no idea why. But to fall back from SSL to non-SSL would require the co-operation of both client and server, a non-SSL client would never attempt to connect to port 443, unless incorrectly configured. So I'm not sure what scenario you are anticipating. Perhaps some industrial environment where you use a special port 8080 or something for ease of configuration of both protocols on the same port? This is hardly a widely needed feature, so development would be hard to justify, except commercially. Angus
  5. ZDeveloper

    Validating an XML using XSD

    procedure TImportExport.CheckXMLByXSD(xml_file, xsd_file: string; out FileName: string); var FXMLDocument: IXMLDOMDocument2; FXMLDOMSchema: IXMLDOMSchemaCollection2; FXMLParserError: IXMLDOMParseError2; s: string; i: integer; flk: IXMLFLK_PType; begin FileName:= ''; try FXMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0') as IXMLDomDocument2; FXMLDOMSchema := CreateOleObject('Msxml2.XMLSchemaCache.6.0') as IXMLDOMSchemaCollection2; FXMLDOMSchema.add('', xsd_file); FXMLDocument.Async := false; FXMLDocument.resolveExternals:= false; FXMLDocument.validateOnParse := false; FXMLDocument.setProperty('MultipleErrorMessages', true); FXMLDocument.load(xml_file); FXMLDocument.schemas := FXMLDOMSchema; FXMLParserError := FXMLDocument.validate as IXMLDOMParseError2; finally if (FXMLParserError.errorCode <> 0) then begin s:= ''; flk:= NewFLK_P; flk.FNAME:= ReplaceFirstChar(ExtractFileName(xml_file),'V'); flk.FNAME_I:= ExtractFileName(xml_file); with FXMLParserError.allErrors do for i:= 0 to Length - 1 do begin with flk.PR.Add do begin case Item[i].ErrorCode of -1072897535: OSHIB:= 903; -1072898028: OSHIB:= 902; end; BAS_EL:= Item[i].errorXPath; COMMENT:= StringReplace(Item[i].reason, #13#10, '', [rfReplaceAll]); end; s:= s + Format('ErrorCode: %d' + #13#10 + 'Reason: %s' + #13#10 + 'SrcText: %s' + #13#10 + 'Line: %d' + #13#10 + 'LinePos: %d' + #13#10 + 'FilePos: %d' + #13#10 + 'XPath: %s', [Item[i].ErrorCode, Item[i].reason, Item[i].Srctext, Item[i].Line, Item[i].LinePos, Item[i].FilePos, Item[i].errorXPath])+ #13#10; end; FileName:= TempFolder + ReplaceFirstChar(ExtractFileName(xml_file),'V'); flk.OwnerDocument.LoadFromXML(XMLDoc.FormatXMLData(flk.OwnerDocument.XML.Text)); flk.OwnerDocument.SaveToFile(FileName); raise Exception.Create('Файл ' + ExtractFileName(xml_file) + ' не соответствует своей XSD схеме ' + ExtractFileName(xsd_file) + #13#10 + s); end; FXMLParserError:= nil; FXMLDOMSchema:= nil; FXMLDocument:= nil; end; end; from project 🙂
  6. David Heffernan

    A gem from the past (Goto)

    I guess you know to use try/finally for this
  7. Rollo62

    Split String

    How about something like TStringHelper.Split ? use System.SysUtils , System.Generics.Collections ; ... var LInput : String; LArray : TArray<String>; LElem : String; LStrQuo : String; begin LInput := '22-1, 22-2, 22-3'; LArray := LInput.Split( [ ',' ], TStringSplitOptions.ExcludeEmpty ); // Ignore empty elements for LElem in LArray do begin LStrQuo := LElem.Trim.QuotedString( '"' ); ... // Do something with the quoted in SQL end; end.
×