ekrich / ekrich/exip

Consider sharing Production(s) in schema generation

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C
Stars
10
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### Issue

`exipg` generates lots of duplicate `Production` structs. In `staticXmlSchema.c`:
- **445 identical EE productions** `{687865855, INDEX_MAX, {URI_MAX, LN_MAX}}`
- **154× SE→NonTerm 16**, **153× SE→NonTerm 15**, **133× SE→NonTerm 9**
- **186× qname {3,50} (annotation)**, **134× {3,56} (attributeGroup)**

Each Production = 16 bytes. **Waste: ~25-30 KB out of 287 KB (10%)**

### Fix

Define shared constants, reference via pointer:
```c
static CONST Production EE_PROD = {687865855, INDEX_MAX, {URI_MAX, LN_MAX}};
static CONST Production SE_ANNOT_81 = {503316485, 81, {3, 50}};

// Use in GrammarRules
static CONST Production* xmlscm_prod_91_0[] = {&EE_PROD, &SE_ANNOT_81, ...};
```

**Tradeoff:** Pointer indirection vs memory savings

### Impact

- **Memory:** 25-30 KB savings (important for embedded)
- **Files:** Modify `exipg.c` code generator
- **Risk:** Low - verify with test suite after regenerating grammars

**Priority:** Low - optimization, not a bug

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in exipg.c to see how the generator emits Production values and GrammarRules, then inspect staticXmlSchema.c for the repeated productions described in the issue. Regenerate grammars and run the test suite; done means shared production references reduce the generated data while tests pass and pointer indirection is acceptable.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.