Author: fejj
Date: 2008-01-23 11:42:27 -0500 (Wed, 23 Jan 2008)
New Revision: 93669
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/pipeline.cpp
Log:
2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
* pipeline.cpp (FileSource::Read): Optimized a bit more for cases
where the caller is trying to read a block larger than our
internal buffer.
(FileSource::Seek): Fixed 'n' to be an int64_t rather than a
uint64_t (which is needed in the case of seeking backwards).
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2008-01-23 16:26:00 UTC (rev 93668)
+++ trunk/moon/src/ChangeLog 2008-01-23 16:42:27 UTC (rev 93669)
@@ -1,3 +1,11 @@
+2008-01-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * pipeline.cpp (FileSource::Read): Optimized a bit more for cases
+ where the caller is trying to read a block larger than our
+ internal buffer.
+ (FileSource::Seek): Fixed 'n' to be an int64_t rather than a
+ uint64_t (which is needed in the case of seeking backwards).
+
2008-01-22 Larry Ewing <[EMAIL PROTECTED]>
* shape.cpp, shape.h: Move the stretch logic out of geometry.cpp
Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-23 16:26:00 UTC (rev 93668)
+++ trunk/moon/src/pipeline.cpp 2008-01-23 16:42:27 UTC (rev 93669)
@@ -1763,7 +1763,7 @@
bool
FileSource::Seek (int64_t offset, int mode)
{
- uint64_t n;
+ int64_t n;
if (fd == -1)
return false;
@@ -1848,7 +1848,7 @@
return -1;
}
- do {
+ while (n > 0) {
if ((r = MIN (buflen, n)) > 0) {
/* copy what we can from our existing buffer */
memcpy (((char *) buf) + nread, bufptr, r);
@@ -1859,22 +1859,30 @@
n -= r;
}
- if (n > 0) {
+ if (n >= sizeof (buffer)) {
+ /* bypass intermediate buffer */
+ bufptr = buffer;
+ if ((r = noint_read (fd, ((char *) buf) + nread, n)) >
0) {
+ nread += r;
+ pos += r;
+ n -= r;
+ }
+ } else if (n > 0) {
/* buffer more data */
if ((r = noint_read (fd, buffer, sizeof (buffer))) > 0)
buflen = (uint32_t) r;
bufptr = buffer;
-
- if (r == -1 && nread == 0)
- return -1;
-
- if (r == 0) {
- eof = true;
- break;
- }
}
- } while (n > 0);
+
+ if (r == -1 && nread == 0)
+ return -1;
+
+ if (r == 0) {
+ eof = true;
+ break;
+ }
+ }
return nread;
}
@@ -2230,7 +2238,7 @@
return -1;
}
- do {
+ while (n > 0) {
if ((r = MIN (buflen, n)) > 0) {
/* copy what we can from our existing buffer */
memcpy (((char *) buf) + nread, bufptr, r);
@@ -2241,24 +2249,30 @@
n -= r;
}
- if (n > 0) {
+ if (n >= sizeof (buffer)) {
+ /* bypass intermediate buffer */
+ bufptr = buffer;
+ if ((r = noint_read (fd, ((char *) buf) + nread, n)) >
0) {
+ nread += r;
+ pos += r;
+ n -= r;
+ }
+ } else if (n > 0) {
/* buffer more data */
if ((r = noint_read (fd, buffer, sizeof (buffer))) > 0)
buflen = (uint32_t) r;
bufptr = buffer;
-
- if (r == -1 && nread == 0) {
- Unlock ();
- return -1;
- }
-
- if (r == 0) {
- eof = true;
- break;
- }
}
- } while (n > 0);
+
+ if (r == -1 && nread == 0)
+ return -1;
+
+ if (r == 0) {
+ eof = true;
+ break;
+ }
+ }
return nread;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches