From b4df57d369ed87cf293fac5085dda7ab7e105f7f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 27 Nov 2015 00:04:33 +0000 Subject: [PATCH] Small cleanups --- src/highlighters.cc | 11 +++++------ src/shell_manager.cc | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 1ef9dfaf..5708801d 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -193,12 +193,6 @@ private: ValueId m_id; }; -static bool overlaps(const BufferRange& lhs, const BufferRange& rhs) -{ - return lhs.begin < rhs.begin ? lhs.end > rhs.begin - : rhs.end > lhs.begin; -} - using FacesSpec = Vector, MemoryDomain::Highlight>; class RegexHighlighter : public Highlighter @@ -212,6 +206,11 @@ public: void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) override { + auto overlaps = [](const BufferRange& lhs, const BufferRange& rhs) { + return lhs.begin < rhs.begin ? lhs.end > rhs.begin + : rhs.end > lhs.begin; + }; + if (flags != HighlightFlags::Highlight or not overlaps(display_buffer.range(), range)) return; diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 100c2185..5aa9ab9c 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -29,7 +29,7 @@ namespace struct Pipe { - Pipe() { pipe(m_fd); } + Pipe() { ::pipe(m_fd); } ~Pipe() { close_read_fd(); close_write_fd(); } int read_fd() const { return m_fd[0]; } @@ -143,7 +143,7 @@ std::pair ShellManager::eval( : FDWatcher(pipe.read_fd(), [&contents, &pipe](FDWatcher& watcher, EventMode) { char buffer[1024]; - size_t size = read(pipe.read_fd(), buffer, 1024); + size_t size = ::read(pipe.read_fd(), buffer, 1024); if (size <= 0) { pipe.close_read_fd();