2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 24 SBuf */
14 #include "base/InstanceId.h"
17 #include "sbuf/Exceptions.h"
18 #include "sbuf/forward.h"
19 #include "sbuf/MemBlob.h"
20 #include "sbuf/Stats.h"
30 /* SBuf placeholder for printf */
32 #define SQUIDSBUFPH "%.*s"
33 #define SQUIDSBUFPRINT(s) (s).plength(),(s).rawContent()
34 #endif /* SQUIDSBUFPH */
36 // TODO: move within SBuf and rename
44 /** Forward input const_iterator for SBufs
46 * Please note that any operation on the underlying SBuf may invalidate
47 * all iterators over it, resulting in undefined behavior by them.
49 class SBufIterator
: public std::iterator
<std::input_iterator_tag
, char>
53 typedef MemBlob::size_type size_type
;
54 bool operator==(const SBufIterator
&s
) const;
55 bool operator!=(const SBufIterator
&s
) const;
57 const char &operator*() const { return *iter
; }
58 SBufIterator
& operator++() { ++iter
; return *this; }
61 SBufIterator(const SBuf
&, size_type
);
63 const char *iter
= nullptr;
66 /** Reverse input const_iterator for SBufs
68 * Please note that any operation on the underlying SBuf may invalidate
69 * all iterators over it, resulting in undefined behavior by them.
71 class SBufReverseIterator
: public SBufIterator
75 SBufReverseIterator
& operator++() { --iter
; return *this;}
76 const char &operator*() const { return *(iter
-1); }
78 SBufReverseIterator(const SBuf
&s
, size_type sz
) : SBufIterator(s
,sz
) {}
83 * Features: refcounted backing store, cheap copy and sub-stringing
84 * operations, copy-on-write to isolate change operations to each instance.
85 * Where possible, we're trying to mimic std::string's interface.
90 typedef MemBlob::size_type size_type
;
91 typedef SBufIterator const_iterator
;
92 typedef SBufReverseIterator const_reverse_iterator
;
93 static const size_type npos
= 0xffffffff; // max(uint32_t)
95 /// Maximum size of a SBuf. By design it MUST be < MAX(size_type)/2. Currently 256Mb.
96 static const size_type maxSize
= 0xfffffff;
98 /// create an empty (zero-size) SBuf
101 SBuf(SBuf
&& S
) : store_(std::move(S
.store_
)), off_(S
.off_
), len_(S
.len_
) {
103 S
.store_
= nullptr; //RefCount supports nullptr, and S is about to be destructed
107 /** Constructor: import c-style string
109 * Create a new SBuf containing a COPY of the contents of the
111 * \param S the c string to be copied
112 * \param n how many bytes to import into the SBuf. If it is npos
113 * or unspecified, imports to end-of-cstring
114 * \note it is the caller's responsibility not to go out of bounds
115 * \note bounds is 0 <= pos < length(); caller must pay attention to signedness
117 explicit SBuf(const char *S
, size_type n
);
118 explicit SBuf(const char *S
);
120 /// Constructor: import std::string. Contents are copied.
121 explicit SBuf(const std::string
&s
);
125 /** Explicit assignment.
127 * Current SBuf will share backing store with the assigned one.
129 SBuf
& assign(const SBuf
&S
);
131 /** Assignment operator.
133 * Current SBuf will share backing store with the assigned one.
135 SBuf
& operator =(const SBuf
& S
) {return assign(S
);}
136 SBuf
& operator =(SBuf
&&S
) {
139 store_
= std::move(S
.store_
);
142 S
.store_
= NULL
; //RefCount supports NULL, and S is about to be destructed
149 /** Import a c-string into a SBuf, copying the data.
151 * It is the caller's duty to free the imported string, if needed.
152 * \param S the c string to be copied
153 * \param n how many bytes to import into the SBuf. If it is npos
154 * or unspecified, imports to end-of-cstring
155 * \note it is the caller's responsibility not to go out of bounds
156 * \note to assign a std::string use the pattern:
157 * assign(stdstr.data(), stdstd.length())
159 SBuf
& assign(const char *S
, size_type n
);
160 SBuf
& assign(const char *S
) {return assign(S
,npos
);}
162 /** Assignment operator. Copy a NULL-terminated c-style string into a SBuf.
164 * Copy a c-style string into a SBuf. Shortcut for SBuf.assign(S)
165 * It is the caller's duty to free the imported string, if needed.
168 SBuf
& operator =(const char *S
) {return assign(S
);}
170 /** reset the SBuf as if it was just created.
172 * Resets the SBuf to empty, memory is freed lazily.
178 * Append the supplied SBuf to the current one; extend storage as needed.
180 SBuf
& append(const SBuf
& S
);
182 /// Append a single character. The character may be NUL (\0).
183 SBuf
& append(const char c
);
185 /** Append operation for C-style strings.
187 * Append the supplied c-string to the SBuf; extend storage
190 * \param S the c string to be copied. Can be NULL.
191 * \param Ssize how many bytes to import into the SBuf. If it is npos
192 * or unspecified, imports to end-of-cstring. If S is NULL,
194 * \note to append a std::string use the pattern
195 * cstr_append(stdstr.data(), stdstd.length())
197 SBuf
& append(const char * S
, size_type Ssize
);
198 SBuf
& append(const char * S
) { return append(S
,npos
); }
200 /** Assignment operation with printf(3)-style definition
201 * \note arguments may be evaluated more than once, be careful
204 SBuf
& Printf(const char *fmt
, ...);
206 /** Append operation with printf-style arguments
207 * \note arguments may be evaluated more than once, be careful
210 SBuf
& appendf(const char *fmt
, ...);
212 /** Append operation, with vsprintf(3)-style arguments.
213 * \note arguments may be evaluated more than once, be careful
216 SBuf
& vappendf(const char *fmt
, va_list vargs
);
218 /// print the SBuf contents to the supplied ostream
219 std::ostream
& print(std::ostream
&os
) const;
221 /** print SBuf contents and debug information about the SBuf to an ostream
223 * Debug function, dumps to a stream informations on the current SBuf,
224 * including low-level details and statistics.
226 std::ostream
& dump(std::ostream
&os
) const;
228 /** random-access read to any char within the SBuf
230 * does not check access bounds. If you need that, use at()
232 char operator [](size_type pos
) const {++stats
.getChar
; return store_
->mem
[off_
+pos
];}
234 /** random-access read to any char within the SBuf.
236 * \throw OutOfBoundsException when access is out of bounds
237 * \note bounds is 0 <= pos < length(); caller must pay attention to signedness
239 char at(size_type pos
) const {checkAccessBounds(pos
); return operator[](pos
);}
241 /** direct-access set a byte at a specified operation.
243 * \param pos the position to be overwritten
244 * \param toset the value to be written
245 * \throw OutOfBoundsException when pos is of bounds
246 * \note bounds is 0 <= pos < length(); caller must pay attention to signedness
247 * \note performs a copy-on-write if needed.
249 void setAt(size_type pos
, char toset
);
251 /** compare to other SBuf, str(case)cmp-style
253 * \param isCaseSensitive one of caseSensitive or caseInsensitive
254 * \param n compare up to this many bytes. if npos (default), compare whole SBufs
255 * \retval >0 argument of the call is greater than called SBuf
256 * \retval <0 argument of the call is smaller than called SBuf
257 * \retval 0 argument of the call has the same contents of called SBuf
259 int compare(const SBuf
&S
, const SBufCaseSensitive isCaseSensitive
, const size_type n
) const;
260 int compare(const SBuf
&S
, const SBufCaseSensitive isCaseSensitive
) const {
261 return compare(S
, isCaseSensitive
, npos
);
264 /// shorthand version for compare()
265 inline int cmp(const SBuf
&S
, const size_type n
) const {
266 return compare(S
,caseSensitive
,n
);
268 inline int cmp(const SBuf
&S
) const {
269 return compare(S
,caseSensitive
,npos
);
272 /// shorthand version for case-insensitive compare()
273 inline int caseCmp(const SBuf
&S
, const size_type n
) const {
274 return compare(S
,caseInsensitive
,n
);
276 inline int caseCmp(const SBuf
&S
) const {
277 return compare(S
,caseInsensitive
,npos
);
280 /// Comparison with a C-string.
281 int compare(const char *s
, const SBufCaseSensitive isCaseSensitive
, const size_type n
) const;
282 int compare(const char *s
, const SBufCaseSensitive isCaseSensitive
) const {
283 return compare(s
,isCaseSensitive
,npos
);
286 /// Shorthand version for C-string compare().
287 inline int cmp(const char *S
, const size_type n
) const {
288 return compare(S
,caseSensitive
,n
);
290 inline int cmp(const char *S
) const {
291 return compare(S
,caseSensitive
,npos
);
294 /// Shorthand version for case-insensitive C-string compare().
295 inline int caseCmp(const char *S
, const size_type n
) const {
296 return compare(S
,caseInsensitive
,n
);
298 inline int caseCmp(const char *S
) const {
299 return compare(S
,caseInsensitive
,npos
);
302 /** check whether the entire supplied argument is a prefix of the SBuf.
303 * \param S the prefix to match against
304 * \param isCaseSensitive one of caseSensitive or caseInsensitive
305 * \retval true argument is a prefix of the SBuf
307 bool startsWith(const SBuf
&S
, const SBufCaseSensitive isCaseSensitive
= caseSensitive
) const;
309 bool operator ==(const SBuf
& S
) const;
310 bool operator !=(const SBuf
& S
) const;
311 bool operator <(const SBuf
&S
) const {return (cmp(S
) < 0);}
312 bool operator >(const SBuf
&S
) const {return (cmp(S
) > 0);}
313 bool operator <=(const SBuf
&S
) const {return (cmp(S
) <= 0);}
314 bool operator >=(const SBuf
&S
) const {return (cmp(S
) >= 0);}
316 /** Consume bytes at the head of the SBuf
318 * Consume N chars at SBuf head, or to SBuf's end,
319 * whichever is shorter. If more bytes are consumed than available,
320 * the SBuf is emptied
321 * \param n how many bytes to remove; could be zero.
322 * npos (or no argument) means 'to the end of SBuf'
323 * \return a new SBuf containing the consumed bytes.
325 SBuf
consume(size_type n
= npos
);
327 /// gets global statistic informations
328 static const SBufStats
& GetStats();
330 /** Copy SBuf contents into user-supplied C buffer.
332 * Export a copy of the SBuf's contents into the user-supplied
333 * buffer, up to the user-supplied-length. No zero-termination is performed
334 * \return num the number of actually-copied chars.
336 size_type
copy(char *dest
, size_type n
) const;
338 /** exports a pointer to the SBuf internal storage.
339 * \warning ACCESSING RAW STORAGE IS DANGEROUS!
341 * Returns a ead-only pointer to SBuf's content. No terminating null
342 * character is appended (use c_str() for that).
343 * The returned value points to an internal location whose contents
344 * are guaranteed to remain unchanged only until the next call
345 * to a non-constant member function of the SBuf object. Such a
346 * call may be implicit (e.g., when SBuf is destroyed
347 * upon leaving the current context).
348 * This is a very UNSAFE way of accessing the data.
349 * This call never returns NULL.
351 * \note the memory management system guarantees that the exported region
352 * of memory will remain valid if the caller keeps holding
353 * a valid reference to the SBuf object and does not write or append to
356 * SBuf foo("some string");
357 * const char *bar = foo.rawContent();
358 * doSomething(bar); //safe
359 * foo.append(" other string");
360 * doSomething(bar); //unsafe
363 const char* rawContent() const;
365 /** Exports a writable pointer to the SBuf internal storage.
366 * \warning Use with EXTREME caution, this is a dangerous operation.
368 * Returns a pointer to the first unused byte in the SBuf's storage,
369 * which can be be used for appending. At least minSize bytes will
370 * be available for writing.
371 * The returned pointer must not be stored by the caller, as it will
372 * be invalidated by the first call to a non-const method call
374 * This call guarantees to never return NULL.
376 * \note Unlike reserveSpace(), this method does not guarantee exclusive
377 * buffer ownership. It is instead optimized for a one writer
378 * (appender), many readers scenario by avoiding unnecessary
379 * copying and allocations.
380 * \throw SBufTooBigException if the user tries to allocate too big a SBuf
382 char *rawSpace(size_type minSize
);
384 /** Obtain how much free space is available in the backing store.
386 * \note: unless the client just cow()ed, it is not guaranteed that
387 * the free space can be used.
389 size_type
spaceSize() const { return store_
->spaceSize(); }
391 /** Force a SBuf's size
392 * \warning use with EXTREME caution, this is a dangerous operation
394 * Adapt the SBuf internal state after external interference
395 * such as writing into it via rawSpace.
396 * \throw TextException if SBuf doesn't have exclusive ownership of store
397 * \throw SBufTooBigException if new size is bigger than available store space
399 void forceSize(size_type newSize
);
401 /** exports a null-terminated reference to the SBuf internal storage.
402 * \warning ACCESSING RAW STORAGE IS DANGEROUS! DO NOT EVER USE
403 * THE RETURNED POINTER FOR WRITING
405 * The returned value points to an internal location whose contents
406 * are guaranteed to remain unchanged only until the next call
407 * to a non-constant member function of the SBuf object. Such a
408 * call may be implicit (e.g., when SBuf is destroyed
409 * upon leaving the current context).
410 * This is a very UNSAFE way of accessing the data.
411 * This call never returns NULL.
413 * \note the memory management system guarantees that the exported region
414 * of memory will remain valid will remain valid only if the
415 * caller keeps holding a valid reference to the SBuf object and
416 * does not write or append to it
420 /// Returns the number of bytes stored in SBuf.
421 size_type
length() const {return len_
;}
423 /** Get the length of the SBuf, as a signed integer
425 * Compatibility function for printf(3) which requires a signed int
426 * \throw SBufTooBigException if the SBuf is too big for a signed integer
428 int plength() const {
429 if (length()>INT_MAX
)
430 throw SBufTooBigException(__FILE__
, __LINE__
);
431 return static_cast<int>(length());
434 /** Check whether the SBuf is empty
436 * \return true if length() == 0
438 bool isEmpty() const {return (len_
==0);}
440 /** Request to guarantee the SBuf's free store space.
442 * After the reserveSpace request, the SBuf is guaranteed to have at
443 * least minSpace bytes of unused backing store following the currently
444 * used portion and single ownership of the backing store.
445 * \throw SBufTooBigException if the user tries to allocate too big a SBuf
447 void reserveSpace(size_type minSpace
) {
448 Must(minSpace
<= maxSize
);
449 Must(length() <= maxSize
- minSpace
);
450 reserveCapacity(length()+minSpace
);
453 /** Request to guarantee the SBuf's store capacity
455 * After this method is called, the SBuf is guaranteed to have at least
456 * minCapacity bytes of total buffer size, including the currently-used
457 * portion; it is also guaranteed that after this call this SBuf
458 * has unique ownership of the underlying memory store.
459 * \throw SBufTooBigException if the user tries to allocate too big a SBuf
461 void reserveCapacity(size_type minCapacity
);
463 /** Accommodate caller's requirements regarding SBuf's storage if possible.
465 * \return spaceSize(), which may be zero
467 size_type
reserve(const SBufReservationRequirements
&requirements
);
471 * Removes SBuf prefix and suffix, leaving a sequence of 'n'
472 * bytes starting from position 'pos', first byte is at pos 0.
473 * It is an in-place-modifying version of substr.
474 * \param pos start sub-stringing from this byte. If it is
475 * npos or it is greater than the SBuf length, the SBuf is cleared and
476 * an empty SBuf is returned.
477 * \param n maximum number of bytes of the resulting SBuf.
478 * npos means "to end of SBuf".
479 * if it is 0, the SBuf is cleared and an empty SBuf is returned.
480 * if it overflows the end of the SBuf, it is capped to the end of SBuf
483 SBuf
& chop(size_type pos
, size_type n
= npos
);
485 /** Remove characters in the toremove set at the beginning, end or both
487 * \param toremove characters to be removed. Stops chomping at the first
488 * found char not in the set
489 * \param atBeginning if true (default), strips at the beginning of the SBuf
490 * \param atEnd if true (default), strips at the end of the SBuf
492 SBuf
& trim(const SBuf
&toRemove
, bool atBeginning
= true, bool atEnd
= true);
494 /** Extract a part of the current SBuf.
496 * Return a fresh a fresh copy of a portion the current SBuf, which is
497 * left untouched. The same parameter convetions apply as for chop.
500 SBuf
substr(size_type pos
, size_type n
= npos
) const;
502 /** Find first occurrence of character in SBuf
504 * Returns the index in the SBuf of the first occurrence of char c.
505 * \return npos if the char was not found
506 * \param startPos if specified, ignore any occurrences before that position
507 * if startPos is npos or greater than length() npos is always returned
508 * if startPos is less than zero, it is ignored
510 size_type
find(char c
, size_type startPos
= 0) const;
512 /** Find first occurrence of SBuf in SBuf.
514 * Returns the index in the SBuf of the first occurrence of the
515 * sequence contained in the str argument.
516 * \param startPos if specified, ignore any occurrences before that position
517 * if startPos is npos or greater than length() npos is always returned
518 * \return npos if the SBuf was not found
520 size_type
find(const SBuf
& str
, size_type startPos
= 0) const;
522 /** Find last occurrence of character in SBuf
524 * Returns the index in the SBuf of the last occurrence of char c.
525 * \return npos if the char was not found
526 * \param endPos if specified, ignore any occurrences after that position.
527 * if npos or greater than length(), the whole SBuf is considered
529 size_type
rfind(char c
, size_type endPos
= npos
) const;
531 /** Find last occurrence of SBuf in SBuf
533 * Returns the index in the SBuf of the last occurrence of the
534 * sequence contained in the str argument.
535 * \return npos if the sequence was not found
536 * \param endPos if specified, ignore any occurrences after that position
537 * if npos or greater than length(), the whole SBuf is considered
539 size_type
rfind(const SBuf
&str
, size_type endPos
= npos
) const;
541 /** Find first occurrence of character of set in SBuf
543 * Finds the first occurrence of ANY of the characters in the supplied set in
545 * \return npos if no character in the set could be found
546 * \param startPos if specified, ignore any occurrences before that position
547 * if npos, then npos is always returned
549 * TODO: rename to camelCase
551 size_type
findFirstOf(const CharacterSet
&set
, size_type startPos
= 0) const;
553 /** Find last occurrence of character of set in SBuf
555 * Finds the last occurrence of ANY of the characters in the supplied set in
557 * \return npos if no character in the set could be found
558 * \param endPos if specified, ignore any occurrences after that position
559 * if npos, the entire SBuf is searched
561 size_type
findLastOf(const CharacterSet
&set
, size_type endPos
= npos
) const;
563 /** Find first occurrence character NOT in character set
565 * \return npos if all characters in the SBuf are from set
566 * \param startPos if specified, ignore any occurrences before that position
567 * if npos, then npos is always returned
569 * TODO: rename to camelCase
571 size_type
findFirstNotOf(const CharacterSet
&set
, size_type startPos
= 0) const;
573 /** Find last occurrence character NOT in character set
575 * \return npos if all characters in the SBuf are from set
576 * \param endPos if specified, ignore any occurrences after that position
577 * if npos, then the entire SBuf is searched
579 size_type
findLastNotOf(const CharacterSet
&set
, size_type endPos
= npos
) const;
581 /// converts all characters to lower case; \see man tolower(3)
584 /// converts all characters to upper case; \see man toupper(3)
587 /// std::string export function
588 std::string
toStdString() const { return std::string(buf(),length()); }
590 const_iterator
begin() const {
591 return const_iterator(*this, 0);
594 const_iterator
end() const {
595 return const_iterator(*this, length());
598 const_reverse_iterator
rbegin() const {
599 return const_reverse_iterator(*this, length());
602 const_reverse_iterator
rend() const {
603 return const_reverse_iterator(*this, 0);
606 // TODO: possibly implement erase() similar to std::string's erase
607 // TODO: possibly implement a replace() call
609 /// SBuf object identifier meant for test cases and debugging.
610 /// Does not change when object does, including during assignment.
611 const InstanceId
<SBuf
> id
;
616 * Keeps SBuf's MemBlob alive in a blob-destroying context where
617 * a seemingly unrelated memory pointer may belong to the same blob.
618 * For [an extreme] example, consider: a.append(a).
619 * Compared to an SBuf temporary, this class is optimized to
620 * preserve blobs only if needed and to reduce debugging noise.
625 Locker(SBuf
*parent
, const char *otherBuffer
) {
626 // lock if otherBuffer intersects the parents buffer area
627 const MemBlob
*blob
= parent
->store_
.getRaw();
628 if (blob
->mem
<= otherBuffer
&& otherBuffer
< (blob
->mem
+ blob
->capacity
))
632 MemBlob::Pointer locket
;
636 MemBlob::Pointer store_
; ///< memory block, possibly shared with other SBufs
637 size_type off_
= 0; ///< our content start offset from the beginning of shared store_
638 size_type len_
= 0; ///< number of our content bytes in shared store_
639 static SBufStats stats
; ///< class-wide statistics
641 /** obtain prototype store
643 * Just-created SBufs all share to the same MemBlob.
644 * This call instantiates and returns it.
646 static MemBlob::Pointer
GetStorePrototype();
649 * obtains a char* to the beginning of this SBuf in memory.
650 * \note the obtained string is NOT null-terminated.
652 char * buf() const {return (store_
->mem
+off_
);}
654 /** returns the pointer to the first char after this SBuf end
656 * No checks are made that the space returned is safe, checking that is
659 char * bufEnd() const {return (store_
->mem
+off_
+len_
);}
662 * Try to guesstimate how big a MemBlob to allocate.
663 * The result is guarranteed to be to be at least the desired size.
665 size_type
estimateCapacity(size_type desired
) const {return (2*desired
);}
667 void reAlloc(size_type newsize
);
669 void cow(size_type minsize
= npos
);
671 void checkAccessBounds(size_type pos
) const;
673 /** Low-level append operation
675 * Takes as input a contiguous area of memory and appends its contents
676 * to the SBuf, taking care of memory management. Does no bounds checking
677 * on the supplied memory buffer, it is the duty of the caller to ensure
678 * that the supplied area is valid.
680 SBuf
& lowAppend(const char * memArea
, size_type areaSize
);
683 /// Named SBuf::reserve() parameters. Defaults ask for and restrict nothing.
684 class SBufReservationRequirements
687 typedef SBuf::size_type size_type
;
690 * Parameters are listed in the reverse order of importance: Satisfaction of
691 * the lower-listed requirements may violate the higher-listed requirements.
692 * For example, idealSpace has no effect unless it exceeds minSpace.
694 size_type idealSpace
= 0; ///< if allocating anyway, provide this much space
695 size_type minSpace
= 0; ///< allocate [at least this much] if spaceSize() is smaller
696 size_type maxCapacity
= SBuf::maxSize
; ///< do not allocate more than this
697 bool allowShared
= true; ///< whether sharing our storage with others is OK
700 /// ostream output operator
701 inline std::ostream
&
702 operator <<(std::ostream
& os
, const SBuf
& S
)
707 /// Returns a lower-cased copy of its parameter.
715 /// Returns an upper-cased copy of its parameter.
724 * Copy an SBuf into a C-string.
726 * Guarantees that the output is a c-string of length
727 * no more than SBuf::length()+1 by appending a \0 byte
728 * to the C-string copy of the SBuf contents.
730 * \note The destination c-string memory MUST be of at least
733 * No protection is added to prevent \0 bytes within the string.
734 * Unexpectedly short strings are a problem for the receiver
735 * to deal with if it cares.
737 * Unlike SBuf::c_str() does not alter the SBuf in any way.
740 SBufToCstring(char *d
, const SBuf
&s
)
742 s
.copy(d
, s
.length());
743 d
[s
.length()] = '\0'; // 0-terminate the destination
744 debugs(1, DBG_DATA
, "built c-string '" << d
<< "' from " << s
);
748 * Copy an SBuf into a C-string.
750 * \see SBufToCstring(char *d, const SBuf &s)
752 * \returns A dynamically allocated c-string based on SBuf.
753 * Use xfree() / safe_free() to release the c-string.
756 SBufToCstring(const SBuf
&s
)
758 char *d
= static_cast<char*>(xmalloc(s
.length()+1));
764 SBufIterator::SBufIterator(const SBuf
&s
, size_type pos
)
765 : iter(s
.rawContent()+pos
)
769 SBufIterator::operator==(const SBufIterator
&s
) const
771 // note: maybe the sbuf comparison is unnecessary?
772 return iter
== s
.iter
;
776 SBufIterator::operator!=(const SBufIterator
&s
) const
778 // note: maybe the sbuf comparison is unnecessary?
779 return iter
!= s
.iter
;
782 #endif /* SQUID_SBUF_H */