Commit Graph

29 Commits

Author SHA1 Message Date
Marco Bubke
0b3d03121f Utils: Modernize SmallString
Use more C++ api and constexpr. With C++ 17 we can use even more.

Change-Id: I33934cd7e087c311bf98501442df848bdb108279
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-05-27 13:09:03 +00:00
Marco Bubke
fded815021 Utils: Use always std::strlen
std::strlen is computed at compile time if possible by the compiler. So
we don't need this optimization.

Change-Id: I31112219df9a3b42fe9d57cdd981f869e6f02dae
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2020-05-12 11:01:41 +00:00
Marco Bubke
bbd58ca30b Clang: Watch directories instead of files
Because there a limited resources to watch files we watch now directories.
So we need much less resources.

Change-Id: Iac558832e9521a7a1a67c5ea99b42ad1b0b5129c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-06-27 12:31:52 +00:00
Ivan Donchevskii
dd778bcb23 Clang: Use full paths in compilation database for symbol collector
We we FilePath and NativeFilePath so that compiler warns us if we mix them
up.

Change-Id: I33d7abc7e4e724dff2a9b2b9b23deea8b358ccfd
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-07 15:03:39 +00:00
Marco Bubke
cc5c899ce0 Utils: Add default constructor to SmallStringView
Change-Id: I3b45f19255cd61ac43807e21fdbf585c9243af26
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-01-14 12:50:48 +00:00
Eike Ziller
f8e88e8ce4 Fix compilation issues with C++17
Testable on Linux/macOS by changing c++14 to c++1z in qtcreator.pri.
Testable with latest MSVC2017 by setting _CL_=/std:c++17.

unary_function, binary_function, and a few other things that were
deprecated are removed in C++17.
std::string got a non-const overload for its "data" member function,
so we cannot create a function pointer on it without specifying its
type. Use std::declval instead (though it requires a default constructor
for the type).

MSVC seems to have an issue with Utils::transform for std::vector
(used in Nim plugin), but that looks like a compiler issue.

Change-Id: I94f9a93d591d55b610f86fabfc618158927d6221
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-06-05 12:04:59 +00:00
Marco Bubke
b6cb22899c Utils: Improve SmallString
The small string control block moved to the beginning, so it is more cache
local. The control block is cleanup too, so it should be easier to read.
The alignment is removed because it is creating to big holes.

Change-Id: I401aeb9d55455cbaa5e722dd8192e54b525ddc40
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-04 13:34:20 +00:00
Marco Bubke
b3bed4c306 Utils: Introduce flexible constructor for SmallString and SmallStringView
If a class has a data method that returns a char pointer it can be 
used to construct a SmallString and a SmallStringView.

Change-Id: I02dcba50babb3074b58998e5f907799e84361ed7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 13:21:52 +00:00
Marco Bubke
a15250051d Clang: Handle native file in the file cache
Different types are introduced for normalized and native file path. So the
compiler is warning you if you try the wrong format.

Change-Id: I1da0686b142cbf9bb7578468c2b50f90a94cebf9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-11-23 11:55:15 +00:00
Marco Bubke
d2e15e5f1e Clang: Add file cache
The database is using file path integer ids to handle file paths because
otherwise we would save many redundant data. This patch is improving it
further with the introduction of a database based file path cache. The
entries are now divided in a directory path and file name. This is quite
handy for directory based file watching.

Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-05 17:36:37 +00:00
Marco Bubke
2fc4e17e31 Utils: Add Utils::SmallStringView::empty
It is required by many template function because it is used in the STL.

Change-Id: I5a2b9266d0c9d79bdc37cbbc4e7b62fac7a82b8b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-21 12:35:24 +00:00
Marco Bubke
fc231309e8 Utils: Fix reverse iterators in SmallString
Change-Id: I859c801fdb1ad68d5943b580f07a9e8260ae192a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-21 12:35:10 +00:00
Marco Bubke
881cd5a799 Utils: Add more constexpr to SmallString
Change-Id: I480ef040a8d9c5b9edc515c7fd58db2fad42dc86
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-30 14:22:01 +00:00
Marco Bubke
f49a1d721c Clang: Add symbol storage
Extend file path cache to 64 bit integer.

Change-Id: I5627f13d59a3214f389087038482cbcc8d0eb484
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:24 +00:00
Marco Bubke
8640ef1927 Utils: Convert to SmallStringView for comparison
Change-Id: I38d9716225b81091e8e75b26c9c2258a2aefa987
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:36:57 +00:00
Marco Bubke
09206ba0e4 Utils: Add explicit conversion operator to QString to SmallStringView
Change-Id: I759651c6426337256b514055132806bf91e93e33
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:47:16 +00:00
Marco Bubke
1ac525bafe Utils: Add _sv literal for SmallStringView
You can now write "text"_sv to get SmallStringView

Change-Id: I4a5172c97b9bfb283360037ebb934c589ad5a2d8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:47:07 +00:00
Marco Bubke
24e5dd0556 Utils: Add compare function for string views
It is more efficient to use compare instead of less and equal together.

Change-Id: I772b03ba02509c0ebc5d5d770be14cf7d5bd431e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:46:38 +00:00
Marco Bubke
793acdb9c6 Utils: Improve SmallStringView::operator==
Change-Id: I5be22e86cdeb7045386633733d2347f48a705578
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 10:04:43 +00:00
Marco Bubke
daa3aad651 Utils: Add startWith to string view
We will add more function if they are needed.

Change-Id: Iac6b432327be32a0778a82c23ed2de5996c555a1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-01 12:40:28 +00:00
Marco Bubke
3b46c09520 Utils: Add isEmpty to string view
Change-Id: Ib7e77602dcdcdf481f6ab690bacef53c5dd92580
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-01 12:40:14 +00:00
Eike Ziller
4ab18cde0e Fix build on Clang/macOS
Broke with dae4477cd3

Change-Id: Ia948d7d70f9e30f2f59b38da231831c0e78c79e1
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-07-05 10:17:17 +00:00
Tim Jenssen
dae4477cd3 Clang: Make file ids unique
Clang file ids are only unique for one query. Because we query in parallel
we have to manage our own unique ids.

Change-Id: I67d57d8b1766cab75ad252a14e57bbf9dc5fdb79
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-03 09:27:05 +00:00
Eike Ziller
63f66f28ac Use _t versions of various type traits
Available now after switching to C++14 and GCC>=4.9

Change-Id: I44e9859a6abe66db16d77b228466b65eadced8ae
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-30 10:46:22 +00:00
Robert Loehning
eeb0b8fd21 Revert "Revert "Utils: Remove old compiler support code""
Thomas provided a smaller fix.
This reverts commit 78fb7f44bf.

Change-Id: I1edff6477526fe4ce29df38852f47fe49117561e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 12:21:43 +00:00
Alessandro Portale
78fb7f44bf Revert "Utils: Remove old compiler support code"
This reverts commit 8a32bcc5e7.

Broke build with MSVC 2015, update 3

Change-Id: Icb59b70fb00ea2a2ecc8d26c8177d21d82aaccf2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 11:47:26 +00:00
Marco Bubke
8a32bcc5e7 Utils: Remove old compiler support code
We now support constexpr, noexcept and alignas on all compilers. Next will
be C++ 14 constexpr support.

Change-Id: I254049c60dcd82fc373ec907cbb5702a4b344978
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-19 10:59:40 +00:00
Marco Bubke
7d342471a4 SmallString: Fix ambiguity of iterators
std::size_t is a undefined unsigned integer type and std::ptrdiff_t is a
undefined signed integer type. So sometimes the compiler doesn't know
which to choose because both could represent a integer.

Change-Id: I669cd44c6f16854dfe3f3cc44edbfc422e1cbd6a
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-06-23 14:08:43 +00:00
Marco Bubke
1eb0c94f81 Utils: Add SmallString
SmallString is a very simple utf8 string class. It's purpose is performance.
It uses a short string opimization which provides 31 bytes of heap free
memory to save a 30 bytes long string plus null terminator. If the string
gets larger heap is allocated. The grow strategy is 1.5 to improve reuse
of allocated memory.

It uses optionally constexpr to provide string literals.

Change-Id: I7757fb51abfeca200d074cbfce2f1d99edc0ecb0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-17 15:07:01 +00:00