[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/devtools/kdevelop-pg/include
From: Andreas Pakulat <apaku () gmx ! de>
Date: 2007-08-21 12:08:15
Message-ID: 1187698095.732970.32423.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 702877 by apaku:
Change the way row/column are calculated. This might be slower than the
existing version, but IMHO its easier to understand and its bug-free (the
existing version doesn't return the right column for the newlines)
M +16 -7 kdev-pg-location-table.h
--- trunk/playground/devtools/kdevelop-pg/include/kdev-pg-location-table.h #702876:702877
@@ -55,14 +55,23 @@
*/
void position_at(std::size_t offset, size_t *line, size_t *column) const
{
- size_t *it = std::lower_bound(lines, lines + current_line, offset);
- assert(it != lines + current_line);
+ std::size_t idx = 0;
+ for( std::size_t i = 0; i < current_line; i++ )
+ {
+ if( lines[i] > offset )
+ {
+ idx = i-1;
+ break;
+ }else if( lines[i] == offset )
+ {
+ idx = i;
+ break;
+ }
- if (*it != offset)
- --it;
+ }
- *line = it - lines;
- *column = offset - (*it + (it != lines));
+ *line = idx;
+ *column = offset - lines[idx];
}
/**
@@ -74,7 +83,7 @@
if (current_line == line_count)
resize(current_line * 2);
- lines[current_line++] = offset;
+ lines[current_line++] = offset+1;
}
inline std::size_t &operator[](int index)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic