-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make ProxyIterator::reference a reference (not a value) in order to truly satisfy random access iterator requirements, because std algs were trying to std::swap rvalues added swap(ProxyIterator &,ProxyIterator &) and (shallow) swap of SizedProxy.Inner() to go with existing deep swap for SizedProxy; I know there are other ProxyIterators but the code I'm building doesn't need swap for those. added a //TODO: comment with a concern I have about SizedProxy's deep swap (which was only recently added); I (graehl) don't understand KenLM well enough to judge. avoid some new gcc 4.8 warnings made compile_query_only.sh respect CXX env var
- Loading branch information
Showing
8 changed files
with
72 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
rm -rf {lm,util,util/double-conversion}/*.o bin/{query,kenlm_max_order,build_binary} | ||
rm -rf {lm,util,util/double-conversion}/*.o bin/{query,build_binary} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,11 @@ class SizedInnerIterator { | |
void *Data() { return ptr_; } | ||
std::size_t EntrySize() const { return size_; } | ||
|
||
friend inline void swap(SizedInnerIterator &first, SizedInnerIterator &second) { | ||
std::swap(first.ptr_, second.ptr_); | ||
std::swap(first.size_, second.size_); | ||
} | ||
|
||
private: | ||
uint8_t *ptr_; | ||
std::size_t size_; | ||
|
@@ -64,9 +69,19 @@ class SizedProxy { | |
const void *Data() const { return inner_.Data(); } | ||
void *Data() { return inner_.Data(); } | ||
|
||
/** | ||
// TODO: this (deep) swap was recently added. why? if any std heap sort etc | ||
// algs are using swap, that's going to be worse performance than using | ||
// =. i'm not sure why we *want* a deep swap. if C++11 compilers are | ||
// choosing between move constructor and swap, then we'd better implement a | ||
// (deep) move constructor. it may also be that this is moot since i made | ||
// ProxyIterator a reference and added a shallow ProxyIterator swap? (I | ||
// need Ken or someone competent to judge whether that's correct also. - | ||
// let me know at [email protected] | ||
*/ | ||
friend void swap(SizedProxy &first, SizedProxy &second) { | ||
std::swap_ranges( | ||
static_cast<char*>(first.inner_.Data()), | ||
static_cast<char*>(first.inner_.Data()), | ||
static_cast<char*>(first.inner_.Data()) + first.inner_.EntrySize(), | ||
static_cast<char*>(second.inner_.Data())); | ||
} | ||
|
@@ -87,7 +102,7 @@ typedef ProxyIterator<SizedProxy> SizedIterator; | |
|
||
inline SizedIterator SizedIt(void *ptr, std::size_t size) { return SizedIterator(SizedProxy(ptr, size)); } | ||
|
||
// Useful wrapper for a comparison function i.e. sort. | ||
// Useful wrapper for a comparison function i.e. sort. | ||
template <class Delegate, class Proxy = SizedProxy> class SizedCompare : public std::binary_function<const Proxy &, const Proxy &, bool> { | ||
public: | ||
explicit SizedCompare(const Delegate &delegate = Delegate()) : delegate_(delegate) {} | ||
|
@@ -106,7 +121,7 @@ template <class Delegate, class Proxy = SizedProxy> class SizedCompare : public | |
} | ||
|
||
const Delegate &GetDelegate() const { return delegate_; } | ||
|
||
private: | ||
const Delegate delegate_; | ||
}; | ||
|