Small cleanups

This commit is contained in:
Maxime Coste 2015-11-27 00:04:33 +00:00
parent a81dbd90a1
commit b4df57d369
2 changed files with 7 additions and 8 deletions

View File

@ -193,12 +193,6 @@ private:
ValueId m_id; 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<std::pair<size_t, String>, MemoryDomain::Highlight>; using FacesSpec = Vector<std::pair<size_t, String>, MemoryDomain::Highlight>;
class RegexHighlighter : public Highlighter class RegexHighlighter : public Highlighter
@ -212,6 +206,11 @@ public:
void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range) override 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)) if (flags != HighlightFlags::Highlight or not overlaps(display_buffer.range(), range))
return; return;

View File

@ -29,7 +29,7 @@ namespace
struct Pipe struct Pipe
{ {
Pipe() { pipe(m_fd); } Pipe() { ::pipe(m_fd); }
~Pipe() { close_read_fd(); close_write_fd(); } ~Pipe() { close_read_fd(); close_write_fd(); }
int read_fd() const { return m_fd[0]; } int read_fd() const { return m_fd[0]; }
@ -143,7 +143,7 @@ std::pair<String, int> ShellManager::eval(
: FDWatcher(pipe.read_fd(), : FDWatcher(pipe.read_fd(),
[&contents, &pipe](FDWatcher& watcher, EventMode) { [&contents, &pipe](FDWatcher& watcher, EventMode) {
char buffer[1024]; char buffer[1024];
size_t size = read(pipe.read_fd(), buffer, 1024); size_t size = ::read(pipe.read_fd(), buffer, 1024);
if (size <= 0) if (size <= 0)
{ {
pipe.close_read_fd(); pipe.close_read_fd();