Title: [149738] trunk/Source/WTF
- Revision
- 149738
- Author
- [email protected]
- Date
- 2013-05-08 08:07:56 -0700 (Wed, 08 May 2013)
Log Message
Avoid unnecessary arguments copying inside GenericHashTraits methods
https://bugs.webkit.org/show_bug.cgi?id=115733
Reviewed by Darin Adler.
Before the change both WTF::GenericHashTraits::passOut and WTF::GenericHashTraits::passOut
used to return the given argument always by value and that caused implicit extra
copying of the argument. It was OK as long as argument type T was POD, as compiler
could optimize it, but in case T was a class having non-trivial copy constructor the
extra copying of the argument could not have been obviated.
The proposed solution is to provide overloaded functions that accept non-temporary
values and return them by reference thus avoiding extra copying.
The proposed solution made an impact on the size of libjavascriptcore_efl.so (EFL
release build): the size decreased from 6554992 bytes to 6554560 bytes.
* wtf/HashTraits.h:
(WTF::GenericHashTraits::passOut):
(WTF::GenericHashTraits::peek):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (149737 => 149738)
--- trunk/Source/WTF/ChangeLog 2013-05-08 14:36:48 UTC (rev 149737)
+++ trunk/Source/WTF/ChangeLog 2013-05-08 15:07:56 UTC (rev 149738)
@@ -1,3 +1,26 @@
+2013-05-08 Mikhail Pozdnyakov <[email protected]>
+
+ Avoid unnecessary arguments copying inside GenericHashTraits methods
+ https://bugs.webkit.org/show_bug.cgi?id=115733
+
+ Reviewed by Darin Adler.
+
+ Before the change both WTF::GenericHashTraits::passOut and WTF::GenericHashTraits::passOut
+ used to return the given argument always by value and that caused implicit extra
+ copying of the argument. It was OK as long as argument type T was POD, as compiler
+ could optimize it, but in case T was a class having non-trivial copy constructor the
+ extra copying of the argument could not have been obviated.
+
+ The proposed solution is to provide overloaded functions that accept non-temporary
+ values and return them by reference thus avoiding extra copying.
+
+ The proposed solution made an impact on the size of libjavascriptcore_efl.so (EFL
+ release build): the size decreased from 6554992 bytes to 6554560 bytes.
+
+ * wtf/HashTraits.h:
+ (WTF::GenericHashTraits::passOut):
+ (WTF::GenericHashTraits::peek):
+
2013-05-07 Anders Carlsson <[email protected]>
Remove AlwaysInline.h from WTF
Modified: trunk/Source/WTF/wtf/HashTraits.h (149737 => 149738)
--- trunk/Source/WTF/wtf/HashTraits.h 2013-05-08 14:36:48 UTC (rev 149737)
+++ trunk/Source/WTF/wtf/HashTraits.h 2013-05-08 15:07:56 UTC (rev 149738)
@@ -78,12 +78,14 @@
// Type for return value of functions that transfer ownership, such as take.
typedef T PassOutType;
static PassOutType passOut(const T& value) { return value; }
+ static T& passOut(T& value) { return value; } // Overloaded to avoid copying of non-temporary values.
// Type for return value of functions that do not transfer ownership, such as get.
// FIXME: We could change this type to const T& for better performance if we figured out
// a way to handle the return value from emptyValue, which is a temporary.
typedef T PeekType;
static PeekType peek(const T& value) { return value; }
+ static T& peek(T& value) { return value; } // Overloaded to avoid copying of non-temporary values.
};
template<typename T> struct HashTraits : GenericHashTraits<T> { };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes