On 22 April 2018 at 19:14, Teodor Petrov <
fusc...@gmail.com> wrote:
> On 04/22/2018 02:09 AM, Neil Hodgson wrote:
>>
>> Some of the changes have been to use more natural types to eliminate
>> casts. C++ like to use size_t for sizes which are 64-bit on 64-bit platforms
>> so I would like to move towards using size_t or ptrdiff_t in more places
>> including the platform interface. There may still need to be casting in
>> platform code as, for example, the Win32 APIs for drawing text use in
>> (32-bit) lengths instead of 64-bit lengths. Even better would be using
>> std::string_view (C++17) for platform APIs as that bundles up the pointer
>> and length.
>
>
> Just keep in mind that size_t is unsigned type and code using unsigned types
> is more buggy
Please provide supporting evidence for such a claim.
> and often slower than code using signed types (compilers optimize better
> code with signed
> types, because signed types doesn't overflow).
Yes compilers optimise better but not because signed types don't
overflow, but because the compiler is allowed to ASSUME they don't
overflow, its undefined behaviour if they do and the compiler can eat
your shorts. Unsigned types on the other hand have defined overflow
behaviour, so the compiler has to obey that and can't optimise away as
much.
But (subject to measurement of course) its unlikely that the
performance will be material for Scintilla, its not an integer math
heavy code.
In general unsigned types
> should be used only
> for flags and when you're sure that you need the extra bit. So at least
> consider using ssize_t
> instead of size_t.
On the other hand the semantic benefits of using unsigned types for
numbers where negatives make no sense is huge.
Cheers
Lex
>
> /Teodor.
>
> --
> You received this message because you are subscribed to the Google Groups
> "scintilla-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
scintilla-inter...@googlegroups.com.
> To post to this group, send email to
scintilla...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/scintilla-interest.
> For more options, visit
https://groups.google.com/d/optout.