rgheck wrote:
On 12/30/2009 04:50 PM, [email protected] wrote:
+bool prev_open_buffer(Buffer *& p_buf) {
+ BufferList::const_iterator it = find(theBufferList().begin(),
theBufferList().end(), p_buf);
+ LASSERT(it != theBufferList().end(), /**/)
+ if (it == theBufferList().begin()) {
+ it = theBufferList().end();
+ --it;
+ p_buf = *it;
+ return true;
+ }
+ --it;
+ p_buf = *it;
+ return false;
+}
Did you consider using BufferList::next() and BufferList::prev() here?
I was about to, but I realized I needed that boolean to tell me when it
starts over from scratch, so I just preferred that. Anyway, using
BufferList::next() it is probably much shorter, like:
p_buf = theBufferList().next(p_buf);
return p_buf == theBufferList().begin();
thx for pointing out (I hadn't thought too much).
} else if (match.opt.scope ==
FindAndReplaceOptions::S_DOCUMENT) {
prompt = next_document_buffer(match.p_buf);
+ } else if (match.opt.scope ==
FindAndReplaceOptions::S_OPEN_BUFFERS) {
+ prompt = next_open_buffer(match.p_buf);
} else {
/* Unimplemented scope */
LASSERT(false, /**/);
Could this be done with a switch? Then the compiler checks.
yes, now that almost all scopes I had in mind are there, a switch is
more convenient.
Just committed in r32682 addressing those issues.
T.