commit eeb22d6936a6cb01a186ea9035e78f3b1acd4dd2
parent d171b735347907503dcd39d9957b3e0fa50fe59b
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Sat, 25 Jul 2015 23:04:11 +0200
Remove those silly @trusted and @safe attributes.
No point in being there if the code is neither safe nor trusted.
Diffstat:
dfortune.d | | | 46 | +++++++++++++++++++++++----------------------- |
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/dfortune.d b/dfortune.d
@@ -19,7 +19,7 @@ class Fortune : RandomAccessFinite!(string){
uint shortlen;
uint flags;
char delim;
- @trusted void read(File f){
+ void read(File f){
ubyte off[getOffset()];
auto red=f.rawRead(off);
version_=bigEndianToNative!(uint,uint.sizeof)(red[0*uint.sizeof..1*uint.sizeof]);
@@ -29,7 +29,7 @@ class Fortune : RandomAccessFinite!(string){
flags=bigEndianToNative!(uint,uint.sizeof)(red[4*uint.sizeof..5*uint.sizeof]);
delim=red[getOffset()-char.sizeof];
}
- @safe static size_t getOffset(){
+ static size_t getOffset(){
return 5*uint.sizeof+char.sizeof;
}
}
@@ -41,26 +41,26 @@ class Fortune : RandomAccessFinite!(string){
uint pos,end;
- @trusted this(string file){
+ this(string file){
basename=file;
src=EncodingScheme.create("UTF-8");
dst=EncodingScheme.create(encodingName!(char));
initialize();
}
- @safe public void initialize(){
+ public void initialize(){
open();
table.seek(0);
header.read(table);
end=header.numstr-1;
}
- @safe public void open(){
+ public void open(){
table.open(basename~".dat","r");
content.open(basename,"r");
}
- @trusted public uint getOffset(uint i){
+ public uint getOffset(uint i){
if(i>header.numstr){
throw new RangeError("Range violation");
}
@@ -70,7 +70,7 @@ class Fortune : RandomAccessFinite!(string){
return bigEndianToNative!(uint,uint.sizeof)(b);
}
- @trusted public string readFortune(uint i){
+ public string readFortune(uint i){
uint pos=getOffset(i);
uint end=getOffset(i+1)-3; //-3 to exclude \n%\n
content.seek(pos);
@@ -92,12 +92,12 @@ class Fortune : RandomAccessFinite!(string){
return cast(string)str;
}
- @safe public void close(){
+ public void close(){
table.close();
content.close();
}
- @safe private Fortune clone(){
+ private Fortune clone(){
Fortune c=new Fortune(this.basename);
c.header=header;
@@ -109,25 +109,25 @@ class Fortune : RandomAccessFinite!(string){
c.end=end;
return c;
}
- @safe @property size_t length(){
+ @property size_t length(){
return header.numstr-pos;
}
- @safe Fortune opSlice(size_t a, size_t b){
+ Fortune opSlice(size_t a, size_t b){
Fortune c=clone();
c.pos=cast(uint)a;
c.end=cast(uint)b;
return c;
}
- @safe @property string back(){
+ @property string back(){
return readFortune(end);
}
- @safe string moveBack(){
+ string moveBack(){
return back;
}
- @safe void popBack(){
+ void popBack(){
end--;
}
- @trusted int opApply(int delegate(string)f){
+ int opApply(int delegate(string)f){
int ret;
while(!empty()){
ret=f(front());
@@ -138,19 +138,19 @@ class Fortune : RandomAccessFinite!(string){
}
return ret;
}
- @safe string moveFront(){
+ string moveFront(){
return readFortune(pos);
}
- @safe @property bool empty(){
+ @property bool empty(){
return (pos>end);
}
- @safe @property string front(){
+ @property string front(){
return moveFront();
}
- @safe void popFront(){
+ void popFront(){
pos++;
}
- @trusted int opApply(int delegate(size_t,string)f){
+ int opApply(int delegate(size_t,string)f){
int ret;
size_t cnt=0;
while(!empty()){
@@ -162,15 +162,15 @@ class Fortune : RandomAccessFinite!(string){
}
return ret;
}
- @safe string moveAt(size_t i){
+ string moveAt(size_t i){
pos=cast(uint)i;
return readFortune(pos);
}
- @safe string opIndex(size_t i){
+ string opIndex(size_t i){
return readFortune(cast(uint)i);
}
- @safe @property Fortune save(){
+ @property Fortune save(){
return clone();
}
}