X-Git-Url: https://code.kerkeslager.com/?p=fur;a=blobdiff_plain;f=c%2Frope.c;h=2cab922c3d158c4ae6eca52ea9f504e00aec449b;hp=716a5af76e999592bf1359812a0742d78b250ef2;hb=378e2971c2f78a9b79453bd47d2ddc658017a44d;hpb=64ef22e135f7c790f0cd80956d8bdf7fa0268148 diff --git a/c/rope.c b/c/rope.c index 716a5af..2cab922 100644 --- a/c/rope.c +++ b/c/rope.c @@ -87,4 +87,13 @@ Rope* Rope_concatenate(Rope* r0, Rope* r1) { return result; } +__attribute__((pure)) size_t Rope_length(Rope* self) { + switch(self->type) { + case ROPETYPE_CONCATENATION: + return Rope_length(self->instance.concatenation.r0) + Rope_length(self->instance.concatenation.r0); + case ROPETYPE_STRING: + return self->instance.string.length; + } +} + #endif