Permalink
Browse files

make invariants const-correct

  • Loading branch information...
1 parent 82402c5 commit f3aa58592faed9a418e347090cd614670947fef4 @WalterBright WalterBright committed Jan 29, 2012
Showing with 7 additions and 6 deletions.
  1. +1 −1 std/mmfile.d
  2. +6 −5 std/stream.d
View
@@ -445,7 +445,7 @@ class MmFile
/**
* Gives size in bytes of the memory mapped file.
*/
- @property ulong length()
+ @property ulong length() const
{
debug (MMFILE) printf("MmFile.length()\n");
return size;
View
@@ -1954,9 +1954,9 @@ class File: Stream {
override size_t readBlock(void* buffer, size_t size) {
assertReadable();
version (Windows) {
- auto dwSize = to!DWORD(size);
+ auto dwSize = to!DWORD(size);
ReadFile(hFile, buffer, dwSize, &dwSize, null);
- size = dwSize;
+ size = dwSize;
} else version (Posix) {
size = core.sys.posix.unistd.read(hFile, buffer, size);
if (size == -1)
@@ -1969,9 +1969,9 @@ class File: Stream {
override size_t writeBlock(const void* buffer, size_t size) {
assertWriteable();
version (Windows) {
- auto dwSize = to!DWORD(size);
+ auto dwSize = to!DWORD(size);
WriteFile(hFile, buffer, dwSize, &dwSize, null);
- size = dwSize;
+ size = dwSize;
} else version (Posix) {
size = core.sys.posix.unistd.write(hFile, buffer, size);
if (size == -1)
@@ -2814,7 +2814,8 @@ class SliceStream : FilterStream {
if (bounded)
assert (pos <= high - low);
else
- assert (pos <= s.size - low);
+ // size() does not appear to be const, though it should be
+ assert (pos <= (cast()s).size - low);
}
override size_t readBlock (void *buffer, size_t size) {

0 comments on commit f3aa585

Please sign in to comment.