Jump to content

Marat1961

Members
  • Content Count

    58
  • Joined

  • Last visited

  • Days Won

    1

Marat1961 last won the day on October 14

Marat1961 had the most liked content!

Community Reputation

17 Good

About Marat1961

  • Birthday 05/16/1961

Technical Information

  • Delphi-Version
    Delphi Community Edition

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Marat1961

    Having fun with Delphi

    System.IOUtils.TPath used for operating the OS file system. File and directory names. At first I missed that the topic was about URLs and I decided that it was about files. The URL is designed to work with Internet entities.
  2. I would use the MCV pattern. The user interface must be subscribed to change the data model. Receiver and consumer must be processes. When the model changes, notify the user interface about the need to update the presentation. Supplier => Consumer => Model MainForm.Refresh; The timer, by the way, is useful in case of a group of changes. So that there is no fuss under the client, it is useful not to draw everything at once, but with some delay of at least 0.2 - 0.5 seconds. procedure TMainForm.RefreshTimerTimer(Sender: TObject); begin RefreshTimer.Enabled: = False; Refresh; end; procedure TMainForm.ModelChanged(Sender: TObject); begin RefreshTimer.Rearm; end;
  3. It was first done well in this book, Hoare, C. A. R. Communicating sequential processes I have a book "Patterns in Java. A Catalog of Reusable Design Patterns Illustrated with UML | Grand Mark". This book describes the Producer-Consumer pattern, in my opinion this is your case. There are code examples for the queue.
  4. This code was definitely not passed through the autoformat. You still don't know what the Soviet norm - control is!
  5. You just need to configure the auto format according to the formatting standard. This format is usually the default. If you think a little, then the following conclusion follows from here: Delphi has only one correct coding standard, and all the others are wrong. When you invite other people to see the code, don't surprise them with your absolutely amazing and most perfect style of code formatting.
  6. Borland / CodeGear / Embarcadero / Jedi coding standard. You can see for example how the formatting of System.Classes
  7. Marat1961

    TMapView Draw route

    Let's try to draw a straight line from point A to point B. Put a button on the form and write in the onClick handler: TPoint = record x, y: Integer; end; procedure DrawLine(A, B: TPoint); begin Form1.Canvas.MoveTo(A.x, A.y); Form1.Canvas.LineTo(B.x, B.y); end; A.x: = 0; A.y: = 0; B.x: = 100; B.y: = 10; DrawLine(A, B);
  8. Marat1961

    TMapView Draw route

    I think that's how it will work! DrawLine (A, B);
  9. Marat1961

    Multiple two UInt64 modulo

    Where will your code in the procedure be faster than the same code generated by the compiler. As far as I understand, the functionality of the code is the same, but the overhead of calling the procedure is added. As a result, if we calculate everything, we lose in performance.
  10. Marat1961

    Multiple two UInt64 modulo

    Can you describe the same as an arithmetic expression? To make it clear and unambiguous. Gigo. Garbage at the input garbage at the output.
  11. Since the most significant digits of the result are not used, there seems to be no difference which multiplication is signed or unsigned. I was tormented by vague doubts, in the end I wrote several tests and did not find any difference when performing multiplication operations for the lower digits of the result. The test code can be viewed here. https://en.delphipraxis.net/topic/3763-multiple-two-uint64-modulo/?tab=comments#comment-31938
  12. Marat1961

    Multiple two UInt64 modulo

    Why is an assembler needed for this operation? If the code is used for example to generate a random number. var seed class: Int64; function of the TRandom64.Def class: Int64; to begin Result: = seed * 6364136223846793005 + 1442695040888963407; seed: = Result; end; then we need a 2 ^ 64 remainder of the products of two Uint64 numbers. To do this, it is enough to multiply two numbers and take the least significant number from the result. Since the leading part of the result is not used, it seems there is no difference which multiplication works signed or unsigned. I was tormented by vague doubts, I wrote several tests and found no difference. type T2Uin64 = record hi, lo: UInt64; end; procedure UMul64 (a, b: UInt64; var r: T2Uin64); asm MOV RAX, a MUL b MOV r.lo, RAX MOV r.hi, RDX end; procedure TForm2.Button2Click (Sender: TObject); const imax32 = Maxint; imax36 = UInt64 (Maxint) * 16; imax63 = 9223372036854775807; umax64 = 18446744073709551615; var a, b, m, c, d, r1, r2: UInt64; r: T2Uin64; begin a: = imax63; b: = 2; d: = umax64 - 1; c: = a * b; r1: = c div m; r2: = (a * b) div m; Assert (c = d); UMul64 (a, b, r); r2: = r.lo div m; d: = r.lo; Assert (d = c); a: = umax64; b: = 2; d: = umax64; c: = a * b; UMul64 (a, b, r); b: = umax64; c: = a * b; UMul64 (umax64, umax64, r); end; If you want to find the remainder again, there is no need to use an assembler. // r2: = (a * b) div m; mov rax, [rbp + 68 $] imul rax, [rbp + $ 60] xor edx, edx div qword ptr [rbp + $ 58] mov [rbp + $ 38], rax It's better than calling an assembler subroutine anyway, because it will be faster. The code becomes portable and will work in both 32-bit and 64-bit implementations and on any platform. In my opinion, optimizing using assembler will only hurt here.
  13. Marat1961

    Multiple two UInt64 modulo

    Karatsuba's algorithm is a fast multiplication algorithm. Karatsuba noted that in fact only three multiplications of n / 2 - digit numbers are enough, since (ad + bc) = (a + b) * (c + d) - ac - bd. That is, using 64/2 = 32 bit numbers, you can get a 64 bit result. N mod m where m = 2 ^ k is a power of two, you can discard bit digits more than k. N mod 2 ^ 32 is a 32 bit number.
  14. Marat1961

    Having fun with Delphi

    A non-empty scheme component followed by a colon (:), consisting of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus (+), period (.), or hyphen (-). Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. Examples of popular schemes include http, https, ftp, mailto, file, data, and irc. URI schemes should be registered with the Internet Assigned Numbers Authority (IANA), although non-registered schemes are used in practice. If we analyze the syntax diagram, we can see that the "non-empty scheme component" and "path component" are required, which is why we included them in Init. A port value of 0 is reserved and means no port is specified. If the value can be present in the URI one time, its value will be replaced by the last usage. The builder is syntax-sensitive and helps to avoid errors when generating URI.
  15. Marat1961

    Having fun with Delphi

    The records do not need to be freed if there are local managed variables, the finalization code is executed before returning from the subroutine. // procedure _FinalizeRecord(p: Pointer; typeInfo: Pointer); 005FD905 8D45D8 lea eax,[ebp-$28] 005FD908 8B1530CF5F00 mov edx,[$005fcf30] 005FD90E E829D6E0FF call @FinalizeRecord 005FD913 C3 ret
×