summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/StringRef.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ADT] Rewrite the StringRef::find implementation to be simpler, clearer,Chandler Carruth2015-09-101-16/+23
| | | | | | | | | | | | | | | | and tremendously less reliant on the optimizer to fix things. The code is always necessarily looking for the entire length of the string when doing the equality tests in this find implementation, but it previously was needlessly re-checking the size each time among other annoyances. By writing this so simply an ddirectly in terms of memcmp, it also is about 8x faster in a debug build, which in turn makes FileCheck about 2x faster in 'ninja check-llvm'. This saves about 8% of the time for FileCheck-heavy parts of the test suite like the x86 backend tests. llvm-svn: 247269
* [ADT] Fix a confusing interface spec and some annoying peculiaritiesChandler Carruth2015-09-101-31/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | with the StringRef::split method when used with a MaxSplit argument other than '-1' (which nobody really does today, but which should actually work). The spec claimed both to split up to MaxSplit times, but also to append <= MaxSplit strings to the vector. One of these doesn't make sense. Given the name "MaxSplit", let's go with it being a max over how many *splits* occur, which means the max on how many strings get appended is MaxSplit+1. I'm not actually sure the implementation correctly provided this logic either, as it used a really opaque loop structure. The implementation was also playing weird games with nullptr in the data field to try to rely on a totally opaque hidden property of the split method that returns a pair. Nasty IMO. Replace all of this with what is (IMO) simpler code that doesn't use the pair returning split method, and instead just finds each separator and appends directly. I think this is a lot easier to read, and it most definitely matches the spec. Added some tests that exercise the corner cases around StringRef() and StringRef("") that all now pass. I'll start using this in code in the next commit. llvm-svn: 247249
* [ADT] Add a single-character version of the small vector split routineChandler Carruth2015-09-101-0/+20
| | | | | | | | | | | on StringRef. Finding and splitting on a single character is substantially faster than doing it on even a single character StringRef -- we immediately get to a *very* tuned memchr call this way. Even nicer, we get to this even in a debug build, shaving 18% off the runtime of TripleTest.Normalization, helping PR23676 some more. llvm-svn: 247244
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-2/+2
| | | | | | just letting them be implicitly created. llvm-svn: 216525
* Remove custom implementations of max/min in StringRef that was originally ↵Craig Topper2014-08-211-9/+9
| | | | | | added to work an old gcc bug. I believe its been fixed by now. llvm-svn: 216156
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-2/+2
| | | | llvm-svn: 205697
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-1/+0
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* Add {start,end}with_lower methods to StringRef.Rui Ueyama2013-10-301-5/+24
| | | | | | | | | startswith_lower is ocassionally useful and I think worth adding. endwith_lower is added for completeness. Differential Revision: http://llvm-reviews.chandlerc.com/D2041 llvm-svn: 193706
* Added const qualifier to StringRef::edit_distance member functionDmitri Gribenko2013-08-241-1/+1
| | | | | | Patch by Ismail Pazarbasi. llvm-svn: 189162
* Revert r185852.Manman Ren2013-07-081-5/+0
| | | | llvm-svn: 185861
* StringRef: add DenseMapInfo for StringRef.Manman Ren2013-07-081-0/+5
| | | | | | | | Remove the implementation in include/llvm/Support/YAMLTraits.h. Added a DenseMap type DITypeHashMap in DebugInfo.h: DenseMap<std::pair<StringRef, unsigned>, MDNode*> llvm-svn: 185852
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+1
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Improve overflow detection in StringRef::getAsUnsignedInteger().Nick Kledzik2012-10-021-2/+2
| | | | llvm-svn: 165038
* [Support/StringRef] Add find_last_not_of and {r,l,}trim.Michael J. Spencer2012-05-111-0/+26
| | | | llvm-svn: 156652
* Don't die with an assertion if the Result bitwidth is already correct. ThisChris Lattner2012-04-231-1/+1
| | | | | | fixes an assert reading "1239123123123123" when the result is already 64-bit. llvm-svn: 155329
* No need for "else if" after a return. Autosense "0o123" as octal inChris Lattner2012-04-211-4/+12
| | | | | | StringRef::getAsInteger llvm-svn: 155298
* Make StringRef::getAsInteger work with all integer types. Before this changeMichael J. Spencer2012-03-101-29/+7
| | | | | | | | it would fail with {,u}int64_t on x86-64 Linux. This also removes code duplication. llvm-svn: 152517
* Add generic support for hashing StringRef objects using the new hashing library.Chandler Carruth2012-03-041-0/+7
| | | | llvm-svn: 152003
* Workaround a miscompilation by gcc-4.3 that showed up as a failureDuncan Sands2012-02-241-1/+1
| | | | | | of the StringRef.Split2 unittest on 32 bit machines. llvm-svn: 151358
* Move the implementation of StringRef::split out of StringExtras.cppDuncan Sands2012-02-211-0/+21
| | | | | | and into StringRef.cpp, which is where the other StringRef stuff is. llvm-svn: 151054
* Add function for computing the edit distance of two arrays.Kaelyn Uhrain2012-02-151-51/+5
| | | | | | | | Accomplished by moving the body of StringRef::edit_distance into a separate function that accepts two ArrayRefs, and making StringRef::edit_distance a wrapper around the new function. llvm-svn: 150621
* Fix a typo.Benjamin Kramer2011-11-061-1/+1
| | | | llvm-svn: 143890
* ADT/StringRef: Add ::lower() and ::upper() methods.Daniel Dunbar2011-11-061-0/+26
| | | | llvm-svn: 143880
* Fix handling of the From parameter in StringRef::find.Benjamin Kramer2011-10-171-2/+5
| | | | | | Enable bounds checking to catch this kind of bug earlier. llvm-svn: 142247
* Add a bad char heuristic to StringRef::find.Benjamin Kramer2011-10-151-3/+26
| | | | | | | | | Based on Horspool's simplified version of Boyer-Moore. We use a constant-sized table of uint8_ts to keep cache thrashing low, needles bigger than 255 bytes are uncommon anyways. The worst case is still O(n*m) but we do a lot better on the average case now. llvm-svn: 142061
* Fix a bug in compare_numeric().Jakob Stoklund Olesen2011-09-301-6/+13
| | | | | | Thanks to Alexandru Dura and Jonas Paulsson for finding it. llvm-svn: 140859
* Remove bounded StringRef::compare() since nothing but Clang SA was using it ↵Lenny Maiorani2011-04-281-21/+0
| | | | | | and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing. llvm-svn: 130430
* Implements StringRef::compare with bounds. It is behaves similarly to ↵Lenny Maiorani2011-04-151-0/+21
| | | | | | strncmp(). Unit tests also included. llvm-svn: 129582
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-2/+2
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129558
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-1/+1
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121120
* Support/ADT/StringRef: Add find_last_of.Michael J. Spencer2010-11-301-0/+15
| | | | llvm-svn: 120495
* Fix Whitespace.Michael J. Spencer2010-11-261-20/+20
| | | | llvm-svn: 120166
* Fix memory leak in StringRef::edit_distance(). 'Allocated' could be leaked ↵Ted Kremenek2010-11-071-5/+6
| | | | | | on an early return. llvm-svn: 118370
* Extend StringRef's edit-distance algorithm to permit an upper bound on the ↵Douglas Gregor2010-10-191-1/+8
| | | | | | allowed edit distance llvm-svn: 116867
* StringRef::compare_numeric also differed from StringRef::compare for ↵Benjamin Kramer2010-08-261-1/+1
| | | | | | characters > 127. llvm-svn: 112189
* Do unsigned char comparisons in StringRef::compare_lower to be more ↵Benjamin Kramer2010-08-261-4/+4
| | | | | | consistent with compare in corner cases. llvm-svn: 112185
* Avoid O(n*m) complexity in StringRef::find_first(_not)_of(StringRef).Benjamin Kramer2010-08-231-4/+13
| | | | | | | | - Cache used characters in a bitset to reduce memory overhead to just 32 bytes. - On my core2 this code is faster except when the checked string was very short (smaller than the list of delimiters). llvm-svn: 111817
* Add StringRef::compare_numeric and use it to sort TableGen register records.Jakob Stoklund Olesen2010-05-261-0/+28
| | | | | | | This means that our Registers are now ordered R7, R8, R9, R10, R12, ... Not R1, R10, R11, R12, R2, R3, ... llvm-svn: 104745
* Add an override to StringRef::getAsInteger which parses into an APInt.John McCall2010-02-281-12/+93
| | | | | | | | | | It gets its own implementation totally divorced from the (presumably performance-sensitive) routines which parse into a uint64_t. Add APInt::operator|=(uint64_t), which is situationally much better than using a full APInt. llvm-svn: 97381
* More trivial optimizations to a function well outside the critical pathDouglas Gregor2010-01-071-15/+8
| | | | llvm-svn: 92896
* Switch StringRef::edit_distance over to using raw pointers, since bothDouglas Gregor2010-01-071-7/+25
| | | | | | | std::vector and llvm::SmallVector have annoying performance tradeoffs. No, I don't expect this to matter, and now it won't. llvm-svn: 92884
* Document the edit-distance algorithm used in StringRef, switch it overDouglas Gregor2009-12-311-5/+14
| | | | | | to SmallVector, and add a unit test. llvm-svn: 92340
* Implement edit distance for StringRefDouglas Gregor2009-12-301-0/+31
| | | | llvm-svn: 92309
* Use StringRef::min instead of std::min.Daniel Dunbar2009-11-191-5/+5
| | | | llvm-svn: 89372
* Add compare_lower and equals_lower methods to StringRef. Switch all users ofBenjamin Kramer2009-11-121-0/+20
| | | | | | StringsEqualNoCase (from StringExtras.h) to it. llvm-svn: 87020
* Add From arguments to StringRef search functions, and tweak doxyments.Daniel Dunbar2009-11-111-9/+24
| | | | | | Also, add unittests for find_first_of and find_first_not_of. llvm-svn: 86770
* Pass StringRef by value.Daniel Dunbar2009-11-061-3/+3
| | | | llvm-svn: 86251
* Workaround what I believe is an MSVC bug where it emits a definition for aDaniel Dunbar2009-09-221-0/+3
| | | | | | | | static const class member into each translation unit, with external linkage??? - If someone understands this issue better, please clue me in, I haven't consulted the standard yet. llvm-svn: 82516
* simplify as daniel suggestsChris Lattner2009-09-201-16/+9
| | | | llvm-svn: 82415
* move a couple non-trivial methods out of line, add new Chris Lattner2009-09-201-0/+71
| | | | | | find_first_of/find_first_of methods. llvm-svn: 82347
OpenPOWER on IntegriCloud