Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: Source/wtf/text/WTFString.h

Issue 141273002: Code problems detected by cppcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/WebPopupMenuImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 614
615 if (is8Bit()) 615 if (is8Bit())
616 return WTF::isAllSpecialCharacters<isSpecialCharacter, LChar>(characters 8(), len); 616 return WTF::isAllSpecialCharacters<isSpecialCharacter, LChar>(characters 8(), len);
617 return WTF::isAllSpecialCharacters<isSpecialCharacter, UChar>(characters16() , len); 617 return WTF::isAllSpecialCharacters<isSpecialCharacter, UChar>(characters16() , len);
618 } 618 }
619 619
620 template<size_t inlineCapacity> 620 template<size_t inlineCapacity>
621 inline void String::appendTo(Vector<UChar, inlineCapacity>& result, unsigned pos , unsigned len) const 621 inline void String::appendTo(Vector<UChar, inlineCapacity>& result, unsigned pos , unsigned len) const
622 { 622 {
623 unsigned numberOfCharactersToCopy = std::min(len, length() - pos); 623 unsigned numberOfCharactersToCopy = std::min(len, length() - pos);
624 if (numberOfCharactersToCopy <= 0) 624 if (!numberOfCharactersToCopy)
625 return; 625 return;
626 result.reserveCapacity(result.size() + numberOfCharactersToCopy); 626 result.reserveCapacity(result.size() + numberOfCharactersToCopy);
627 if (is8Bit()) { 627 if (is8Bit()) {
628 const LChar* characters8 = m_impl->characters8(); 628 const LChar* characters8 = m_impl->characters8();
629 for (size_t i = 0; i < numberOfCharactersToCopy; ++i) 629 for (size_t i = 0; i < numberOfCharactersToCopy; ++i)
630 result.uncheckedAppend(characters8[pos + i]); 630 result.uncheckedAppend(characters8[pos + i]);
631 } else { 631 } else {
632 const UChar* characters16 = m_impl->characters16(); 632 const UChar* characters16 = m_impl->characters16();
633 result.append(characters16 + pos, numberOfCharactersToCopy); 633 result.append(characters16 + pos, numberOfCharactersToCopy);
634 } 634 }
635 } 635 }
636 636
637 template<typename BufferType> 637 template<typename BufferType>
638 inline void String::appendTo(BufferType& result, unsigned pos, unsigned len) con st 638 inline void String::appendTo(BufferType& result, unsigned pos, unsigned len) con st
639 { 639 {
640 unsigned numberOfCharactersToCopy = std::min(len, length() - pos); 640 unsigned numberOfCharactersToCopy = std::min(len, length() - pos);
641 if (numberOfCharactersToCopy <= 0) 641 if (!numberOfCharactersToCopy)
642 return; 642 return;
643 if (is8Bit()) 643 if (is8Bit())
644 result.append(m_impl->characters8() + pos, numberOfCharactersToCopy); 644 result.append(m_impl->characters8() + pos, numberOfCharactersToCopy);
645 else 645 else
646 result.append(m_impl->characters16() + pos, numberOfCharactersToCopy); 646 result.append(m_impl->characters16() + pos, numberOfCharactersToCopy);
647 } 647 }
648 648
649 template<size_t inlineCapacity> 649 template<size_t inlineCapacity>
650 inline void String::prependTo(Vector<UChar, inlineCapacity>& result, unsigned po s, unsigned len) const 650 inline void String::prependTo(Vector<UChar, inlineCapacity>& result, unsigned po s, unsigned len) const
651 { 651 {
652 unsigned numberOfCharactersToCopy = std::min(len, length() - pos); 652 unsigned numberOfCharactersToCopy = std::min(len, length() - pos);
653 if (numberOfCharactersToCopy <= 0) 653 if (!numberOfCharactersToCopy)
654 return; 654 return;
655 if (is8Bit()) { 655 if (is8Bit()) {
656 size_t oldSize = result.size(); 656 size_t oldSize = result.size();
657 result.resize(oldSize + numberOfCharactersToCopy); 657 result.resize(oldSize + numberOfCharactersToCopy);
658 memmove(result.data() + numberOfCharactersToCopy, result.data(), oldSize * sizeof(UChar)); 658 memmove(result.data() + numberOfCharactersToCopy, result.data(), oldSize * sizeof(UChar));
659 StringImpl::copyChars(result.data(), m_impl->characters8() + pos, number OfCharactersToCopy); 659 StringImpl::copyChars(result.data(), m_impl->characters8() + pos, number OfCharactersToCopy);
660 } else { 660 } else {
661 result.prepend(m_impl->characters16() + pos, numberOfCharactersToCopy); 661 result.prepend(m_impl->characters16() + pos, numberOfCharactersToCopy);
662 } 662 }
663 } 663 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 using WTF::charactersToFloat; 700 using WTF::charactersToFloat;
701 using WTF::equal; 701 using WTF::equal;
702 using WTF::equalIgnoringCase; 702 using WTF::equalIgnoringCase;
703 using WTF::find; 703 using WTF::find;
704 using WTF::isAllSpecialCharacters; 704 using WTF::isAllSpecialCharacters;
705 using WTF::isSpaceOrNewline; 705 using WTF::isSpaceOrNewline;
706 using WTF::reverseFind; 706 using WTF::reverseFind;
707 707
708 #include "wtf/text/AtomicString.h" 708 #include "wtf/text/AtomicString.h"
709 #endif 709 #endif
OLDNEW
« no previous file with comments | « Source/web/WebPopupMenuImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698