summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-29 13:49:45 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-29 13:49:45 +0000
commit753f3a50d10e43134ebeb52b3ec0a10b7ec2b80a (patch)
tree3e05af94f1bf6fa1d4c22cfe70ce1dea22691aa6 /src
parent0cb192921ad068dd6a9c81d71c5c0e16d9c9b185 (diff)
Make StringView and unit types trivial types
Diffstat (limited to 'src')
-rw-r--r--src/command_manager.cc2
-rw-r--r--src/file.cc2
-rw-r--r--src/insert_completer.cc2
-rw-r--r--src/main.cc2
-rw-r--r--src/ranked_match.hh2
-rw-r--r--src/string.hh8
-rw-r--r--src/units.hh18
7 files changed, 25 insertions, 11 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 44900c4f..6b79df3c 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -47,6 +47,8 @@ namespace
struct Reader
{
public:
+ Reader(StringView s) : str{s}, pos{}, coord{} {}
+
[[gnu::always_inline]]
char operator*() const { return str[pos]; }
diff --git a/src/file.cc b/src/file.cc
index 6c55050c..f5704d71 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -86,7 +86,7 @@ String real_path(StringView filename)
char buffer[PATH_MAX+1];
StringView existing = filename;
- StringView non_existing;
+ StringView non_existing{};
while (true)
{
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index 239da7cc..90ce1b7d 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -516,7 +516,7 @@ bool InsertCompleter::try_complete(Func complete_func)
kak_assert(m_completions.begin <= sels.main().cursor());
m_current_candidate = m_completions.candidates.size();
menu_show();
- m_completions.candidates.push_back({sels.buffer().string(m_completions.begin, m_completions.end), ""});
+ m_completions.candidates.push_back({sels.buffer().string(m_completions.begin, m_completions.end), "", {}});
return true;
}
diff --git a/src/main.cc b/src/main.cc
index a41ebad1..5e84812d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -249,7 +249,7 @@ void register_options()
Vector<String, MemoryDomain::Options>({ "./", "/usr/include" }));
reg.declare_option("completers", "insert mode completers to execute.",
InsertCompleterDescList({
- InsertCompleterDesc{ InsertCompleterDesc::Filename },
+ InsertCompleterDesc{ InsertCompleterDesc::Filename, {} },
InsertCompleterDesc{ InsertCompleterDesc::Word, "all"_str }
}), OptionFlags::None);
reg.declare_option("static_words", "list of words to always consider for insert word completion",
diff --git a/src/ranked_match.hh b/src/ranked_match.hh
index 4a56528a..bac6bc39 100644
--- a/src/ranked_match.hh
+++ b/src/ranked_match.hh
@@ -44,7 +44,7 @@ private:
FullMatch = 1 << 5,
};
- StringView m_candidate;
+ StringView m_candidate{};
Flags m_flags = Flags::None;
int m_word_boundary_match_count = 0;
int m_max_index = 0;
diff --git a/src/string.hh b/src/string.hh
index 8ce6ded5..14e92bd7 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -211,7 +211,7 @@ private:
class StringView : public StringOps<StringView, const char>
{
public:
- constexpr StringView() = default;
+ StringView() = default;
constexpr StringView(const char* data, ByteCount length)
: m_data{data}, m_length{length} {}
constexpr StringView(const char* data) : m_data{data}, m_length{data ? strlen(data) : 0} {}
@@ -248,10 +248,12 @@ public:
ZeroTerminatedString zstr() const { return {begin(), end()}; }
private:
- const char* m_data = nullptr;
- ByteCount m_length = 0;
+ const char* m_data;
+ ByteCount m_length;
};
+static_assert(std::is_trivial<StringView>::value, "");
+
template<typename Type, typename CharType>
inline StringView StringOps<Type, CharType>::substr(ByteCount from, ByteCount length) const
{
diff --git a/src/units.hh b/src/units.hh
index e7f853e6..0218055f 100644
--- a/src/units.hh
+++ b/src/units.hh
@@ -13,6 +13,8 @@ template<typename RealType, typename ValueType = int>
class StronglyTypedNumber
{
public:
+ StronglyTypedNumber() = default;
+
[[gnu::always_inline]]
explicit constexpr StronglyTypedNumber(ValueType value)
: m_value(value)
@@ -124,8 +126,10 @@ protected:
struct LineCount : public StronglyTypedNumber<LineCount, int>
{
+ LineCount() = default;
+
[[gnu::always_inline]]
- constexpr LineCount(int value = 0) : StronglyTypedNumber<LineCount>(value) {}
+ constexpr LineCount(int value) : StronglyTypedNumber<LineCount>(value) {}
};
[[gnu::always_inline]]
@@ -136,8 +140,10 @@ inline constexpr LineCount operator"" _line(unsigned long long int value)
struct ByteCount : public StronglyTypedNumber<ByteCount, int>
{
+ ByteCount() = default;
+
[[gnu::always_inline]]
- constexpr ByteCount(int value = 0) : StronglyTypedNumber<ByteCount>(value) {}
+ constexpr ByteCount(int value) : StronglyTypedNumber<ByteCount>(value) {}
};
[[gnu::always_inline]]
@@ -148,8 +154,10 @@ inline constexpr ByteCount operator"" _byte(unsigned long long int value)
struct CharCount : public StronglyTypedNumber<CharCount, int>
{
+ CharCount() = default;
+
[[gnu::always_inline]]
- constexpr CharCount(int value = 0) : StronglyTypedNumber<CharCount>(value) {}
+ constexpr CharCount(int value) : StronglyTypedNumber<CharCount>(value) {}
};
[[gnu::always_inline]]
@@ -160,8 +168,10 @@ inline constexpr CharCount operator"" _char(unsigned long long int value)
struct ColumnCount : public StronglyTypedNumber<ColumnCount, int>
{
+ ColumnCount() = default;
+
[[gnu::always_inline]]
- constexpr ColumnCount(int value = 0) : StronglyTypedNumber<ColumnCount>(value) {}
+ constexpr ColumnCount(int value) : StronglyTypedNumber<ColumnCount>(value) {}
};
[[gnu::always_inline]]