Conversation
- Changed compare method to use compact() instead of encode() - Removed off on off off off off off off off off on off on off off off off off on off off off on on off off off off on off off off off off off off off off off off off on off off off off off off off on off on on off off off on off off on off off on off off on off on off off on off on off off off off on off off off on off off on off off off off off off off off on off on off off on off off off off off off off off off off off off on off off off on off on off on on off off off off on on on off on on off on off on on off off off off on on off off on off off off off off on off off on off off on off off off off off off on off off off off on on off on off off off off off on off on off off off off off off off off off off on on off on off off off parameter since compare should always showcase best-case savings - Ensures TOON's token efficiency is properly demonstrated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
comparemethod to usecompact()instead ofencode()$optionsparameter since compare should always showcase best-case savingscomparemethodRationale
The
comparemethod is designed to showcase the benefits of using TOON over JSON by comparing token usage. Previously, it accepted an optional$optionsparameter and usedencode(), which meant the comparison could use any format (compact, readable, or tabular).This change:
compactformat, which provides the best token savings$optionsparameterChanges
Modified
src/Toon.php- Updatedcompare()method:?EncodeOptions $options = nullparameter$toon = self::encode($value, $options)to$toon = self::compact($value)Testing
Run the examples in
compact_benefits.phpto verify that token savings are properly showcased.```bash
php compact_benefits.php
```
Branch
This PR targets the
mainbranch (v2.x), which supports PHP 8.1+.