Another Inform 7 performance question

I recently adapted Numbered Disambiguation Choices by Aaron Reed to support rooms as well as things, and noticed that this line causes a substantial performance hit:

Understand the disambiguation id property as describing a room. (The disambiguation id is a number property that every room and thing has.)

I was wondering if anyone could shed some light on why this is so slow, and if anyone has any ideas about how to make it faster. I guess it causes a lot of extra work for the parser. Would it be possible to somehow use a dictionary word address rather than a number, and then create dictionary words for, say, ‘1’ to ‘20’, unless they already exist?

EDIT: I tried replacing the line above with a lot of Understand "1" as a room when the disambiguation id of the item described is 1. and so on, but that turned out to be much slower.

You can try using a KOV instead of a number for the disambiguation ID:

A disvalue is a kind of value. The disvalues are s0, s1, s2, s3, s4.
Understand "0" as s0.
Understand "1" as s1.
Understand "2" as s2.
Understand "3" as s3.
Understand "4" as s4.

A thing has a disvalue.
Understand the disvalue property as describing a thing.

This should be somewhat faster, although I7’s flexible object-naming is never super-efficient.

Yay, that was faster. 46,195,328 cycles saved in a full playthrough! Thanks a lot!

EDIT: I committed the implementation here.