git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
368f244
)
Added a simple cache for xhr objects in the xhr transport.
author
jaubourg
<j@ubourg.net>
Sun, 9 Jan 2011 03:03:00 +0000
(
04:03
+0100)
committer
jaubourg
<j@ubourg.net>
Sun, 9 Jan 2011 03:03:00 +0000
(
04:03
+0100)
src/ajax/xhr.js
patch
|
blob
|
history
diff --git
a/src/ajax/xhr.js
b/src/ajax/xhr.js
index
7d71402
..
032668f
100644
(file)
--- a/
src/ajax/xhr.js
+++ b/
src/ajax/xhr.js
@@
-6,6
+6,9
@@
var // Next fake timer id
// Callbacks hashtable
xhrs = {},
// Callbacks hashtable
xhrs = {},
+ // XHR pool
+ xhrPool = [],
+
// #5280: see end of file
xhrUnloadAbortMarker = [];
// #5280: see end of file
xhrUnloadAbortMarker = [];
@@
-21,7
+24,7
@@
jQuery.ajax.transport( function( s , determineDataType ) {
send: function(headers, complete) {
send: function(headers, complete) {
- var xhr = s.xhr(),
+ var xhr = xhrPool.pop() || s.xhr(),
handle;
// Open the socket
handle;
// Open the socket
@@
-53,6
+56,8
@@
jQuery.ajax.transport( function( s , determineDataType ) {
try {
xhr.send( ( s.hasContent && s.data ) || null );
} catch(e) {
try {
xhr.send( ( s.hasContent && s.data ) || null );
} catch(e) {
+ // Store back in pool
+ xhrPool.push( xhr );
complete(0, "error", "" + e);
return;
}
complete(0, "error", "" + e);
return;
}
@@
-64,10
+69,12
@@
jQuery.ajax.transport( function( s , determineDataType ) {
if ( callback && ( abortStatusText || xhr.readyState === 4 ) ) {
// Do not listen anymore
if ( callback && ( abortStatusText || xhr.readyState === 4 ) ) {
// Do not listen anymore
+ // and Store back in pool
if (handle) {
xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ];
handle = undefined;
if (handle) {
xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ];
handle = undefined;
+ xhrPool.push( xhr );
}
callback = 0;
}
callback = 0;