zoukankan      html  css  js  c++  java
  • 分析模板的一段简单快速的算法片段

    char[] templateText = txt.ToCharArray();
                
    //ITemplate it = new CleanTemplate();

                List
    <Tag> tags = new List<Tag>();
                
    char[] temp = new char[100];

                
    for (int i = 0; i < templateText.Length; i++)
                {
                    
    if (templateText[i] == '{')
                    {
                        
    if (i > 0 && templateText[i - 1== '\\')
                            
    continue;

                        Tag tag 
    = new Tag();
                        tag.StartIndex 
    = i;
                        context.Response.Write(templateText[i]);

                        
    while (++< templateText.Length && templateText[i] != '}')
                        {
                            
    if (templateText[i] == ' ')
                            {
                                
    if (isFirstSpace)
                                {
                                    isFirstSpace 
    = false;
                                    context.Response.Write(
    " ");
                                }
                                
    continue;
                            }
                            context.Response.Write(templateText[i]);
                        }
                        tag.EndIndex 
    = i;
                        context.Response.Write(templateText[i]);
                        context.Response.Write(
    "<br />");
                    }

                    isFirstSpace 
    = true;
                }

  • 相关阅读:
    SpringBoot启动方式
    自制反汇编逆向分析工具
    libdispatch.dylib中dispatch_group的实现
    深入ObjC GCD中的dispatch group工作原理。
    objc反汇编分析,手工逆向libsystem_blocks.dylib
    UML分析AsyncDisplayKit框架-ASMuplexImageNode异步下载时序图。
    objc反汇编分析,block函数块为何物?
    apple平台下的objc的GCD,多线程编程就是优雅自然。
    AsyncDisplayKit编译和使用注意事项
    反汇编objc分析__block
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2011-2022 走看看