]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/source-file.cc
diff --git a/ChangeLog b/ChangeLog
[lilypond.git] / lily / source-file.cc
index f1dd4a36942ed73d973f5f139795f4ae23ef0512..57d67b464b6e16b83d14ca454b841197ba2bcacc 100644 (file)
@@ -326,23 +326,13 @@ Source_file::get_line (char const *pos_str0) const
   if (!newline_locations_.size ())
     return 1;
 
-  vsize lo = 0;
-  vsize hi = newline_locations_.size ();
+  /* this will find the '\n' character at the end of our line */
+  vsize lo = lower_bound (newline_locations_,
+                         pos_str0,
+                         less<char const*> ());
 
-  if (newline_locations_[lo] > pos_str0)
-    return 1;
-
-  if (newline_locations_[hi - 1] < pos_str0)
-    return hi;
-
-  binary_search_bounds (newline_locations_,
-                       (char const*&)pos_str0,
-                       default_compare,
-                       &lo, &hi);
-
-  if (*pos_str0 == '\n')
-    lo--;
-  return lo + 2 + line_offset_;
+  /* the return value will be indexed from 1 */
+  return lo + 1 + line_offset_;
 }
 
 void